A method, system, and program product for state estimation of DC microgrids under FDI attacks based on deep learning and Kalman filtering.
By combining deep learning with Kalman filtering, the accuracy and security issues of DC microgrid state estimation are solved, achieving high-precision state estimation and fast recovery under FDI attacks, which is applicable to complex DC microgrids with distributed energy integration.
Patent Information
- Application Number
- CN202611359663.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-03
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2046-09-03
AI Technical Summary
Existing dynamic state estimation methods for DC microgrids are difficult to construct accurate physical models and are susceptible to FDI attacks that lead to distorted state estimations. They also lack effective attack detection and mitigation mechanisms, failing to meet the high accuracy and security requirements of complex DC microgrids.
We employ a deep learning and Kalman filtering approach, extracting temporal features using Transformer-LSTM, constructing the state space using ARIMA, optimizing the noise covariance using the EM algorithm, detecting FDI attacks using KL divergence, and compensating for the attack impact through a trust consistency correction strategy, outputting robust estimation results.
It achieves high-precision state estimation of DC microgrids under FDI attacks, with strong anti-interference ability, wide adaptability, and can quickly recover accurate state estimation results. It is suitable for complex DC microgrids with distributed energy integration.
Smart Images

Figure CN122845312B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of dynamic state estimation technology for DC microgrids, specifically to the fusion of deep learning and Kalman filtering, and the detection and mitigation of FDI (False Data Injection) attacks. It belongs to the interdisciplinary field of distributed energy system control and network security, and is applicable to the operation monitoring and state optimization of DC microgrids containing distributed energy sources. It is mainly a method, system, and program product for state estimation of DC microgrids under FDI attacks based on deep learning and Kalman filtering. Background Technology
[0002] With the widespread integration of distributed energy resources into DC microgrids, the power grid exhibits complex dynamic characteristics, making the demand for high-precision dynamic state estimation increasingly urgent. Dynamic state estimation is the core foundation for achieving stable control, fault diagnosis, and optimized scheduling of DC microgrids, and its accuracy directly determines the safety and reliability of power grid operation.
[0003] Traditional dynamic state estimation methods for DC microgrids rely on complete and accurate system physical models. However, the diversity of distributed energy sources, the randomness of loads, and the time-varying nature of component parameters make it difficult to construct accurate physical models covering all operating conditions, significantly limiting the applicability of traditional methods. Furthermore, in actual operation, issues such as limited measurement data, significant noise interference, and model mismatch further reduce the accuracy of traditional dynamic state estimation, failing to meet the operational requirements of complex DC microgrids.
[0004] More importantly, the networked nature of DC microgrids makes them vulnerable to malicious network attacks, with FDI attacks being particularly typical. These attacks inject falsified information into measurement data, tampering with the Kalman filter's innovation sequence, leading to severely distorted state estimation results, and consequently causing safety incidents such as control decision errors and malfunctions of protection devices.
[0005] Existing dynamic state estimation methods lack effective FDI attack detection and mitigation mechanisms. On the one hand, traditional anomaly detection methods have difficulty distinguishing between FDI attacks and normal measurement noise, resulting in high false alarm and false negative rates. On the other hand, even if an attack is detected, there is a lack of distributed robust state reconstruction methods, making it impossible to quickly recover accurate state estimation results.
[0006] In addition, traditional Kalman filtering methods have the problem of difficulty in accurately determining the noise covariance matrix and initial state, which makes the filtering accuracy significantly affected by parameter settings. At the same time, traditional methods cannot effectively extract long-term time-series dependency features from measurement data and have insufficient adaptability in multi-condition switching scenarios.
[0007] Therefore, developing a dynamic state estimation method for DC microgrids that does not rely on an accurate physical model, has strong anti-interference capabilities, and can effectively resist FDI attacks has become a key requirement in the field. Summary of the Invention
[0008] This invention overcomes the shortcomings of the prior art and provides a method, system, and program product for state estimation of DC microgrids under FDI attacks based on deep learning and Kalman filtering; it has anti-interference capabilities and can resist FDI attacks.
[0009] To achieve the above objectives, the technical solution adopted by this invention is: a method for state estimation of DC microgrids under FDI attacks based on deep learning and Kalman filtering, comprising: Step S1: Construct a state-space model of a DC microgrid to describe the power dynamics of the distributed generation unit (DGU) and the line, and obtain a discrete-time state-space model. Step S2: Establish a TKF fusion framework. The Transformer-LSTM feature extraction module within the TKF (Transformer-Kalman Filtering) framework extracts the spatiotemporal features of the microgrid's voltage or current time-series data. The ARIMA (Auto Regressive Integrated Moving Average) model transforms the feature sequence of the spatiotemporal features into a Kalman-filter-compatible state space, generating Kalman-filter-compatible state and observation relationships. The EM algorithm iteratively optimizes the process noise covariance and observation noise covariance of the Kalman filter. Combining the obtained discrete-time state-space model, the prediction-correction loop of the Kalman filter is executed, outputting the preliminary state estimation results of the DC microgrid and the Kalman filter innovation sequence. Step S3: Perform FDI attack anomaly detection based on KL divergence. Calculate the KL divergence using the obtained Kalman filter innovation sequence to identify FDI attacks present in the measurement data. Step S4: Complete attack compensation based on trust consistency correction, and output robust estimation results, including: When an FDI attack is detected, a trust consistency correction strategy is adopted to weight and fuse the state estimates of each node to compensate for the estimation bias caused by the attack, and output the final robust estimate as the robust estimation result.
[0010] In a preferred embodiment of the present invention, step S1, establishing the state-space model of the DC microgrid includes: The state vector is defined as a set of output current, output voltage, and line current of the distributed generation unit, and the control input vector is the control signal of each distributed generation unit. Directed graphs are used to depict the dynamic relationship between electrical nodes and lines, i.e. the power dynamics between distributed generation units and lines, and as the system dynamics, a continuous-time state-space model is established to describe the system dynamics. The continuous-time state-space model is discretized using the forward Euler method to obtain the discrete-time state-space model.
[0011] In a preferred embodiment of the present invention, in step S1, the continuous-time state-space model encompasses the system dynamics, which include: The current dynamics of distributed generation units reflect inductive characteristics; The voltage dynamics of distributed generation units reflect the effects of capacitance, load resistance, and constant power load. The dynamic current of the line current in a distributed generation unit reflects the line impedance characteristics.
[0012] In a preferred embodiment of the present invention, in step S2, the Transformer-LSTM feature extraction module includes an LSTM network and a Transformer self-attention mechanism; The LSTM network is configured with 4 layers and uses a gating mechanism to capture short-term temporal dependencies. The Transformer self-attention mechanism calculates weights using Query (query vector) / Key (key vector) / Value (value vector), superimposes positional encoding to inject sequence order information, extracts spatiotemporal features, and arranges them according to time step encoding to obtain a feature sequence; The ARIMA model determines its order based on the characteristics of the feature sequence input to the Transformer-LSTM feature extraction module, converts the feature sequence into a Kalman-compatible state space, and expands the state vector. The process noise covariance, observation noise covariance, and initial state parameters of the Kalman algorithm are iteratively optimized using the EM algorithm until the parameter changes are less than 1e-5 and convergence is achieved, thus obtaining a preliminary state estimate.
[0013] In a preferred embodiment of the present invention, the FDI attack model is used to quantify the logic of attacks that tamper with measurement and innovation sequences. The establishment of the FDI attack model includes: The post-attack measurement value is represented as the superposition of the normal measurement value and the attack vector. An attack identification variable is introduced to distinguish whether an attack has occurred. The destructive impact of FDI attacks on Kalman filter innovation sequences is analyzed. FDI attack detection is achieved based on KL divergence and k-NN. A nominal innovation distribution is established using attack-free data. The KL divergence between the Kalman filter innovation sequence and the nominal innovation distribution is calculated in real time. When the calculated KL divergence exceeds a preset threshold, an attack alarm is triggered.
[0014] In a preferred embodiment of the present invention, in step S4, a confidence-trust consensus mechanism is used to mitigate the impact of attacks. Each node calculates its self-confidence and neighbor trust, and the smaller the KL divergence, the higher the confidence.
[0015] In a preferred embodiment of the present invention, the invention further includes a verification model, which verifies the effectiveness of the model in a DC microgrid scenario under no-attack, FDI-attack, and secondary control modes, determines error indicators, and continuously iteratively optimizes the parameters and detection thresholds of the TKF fusion framework based on the error to adapt to the dynamic changes of the DC microgrid.
[0016] In a preferred embodiment of the present invention, the physical model of the DC microgrid includes: The state vector is: Where I = (I1, I2, ..., I n T is the set of output currents of n distributed generation units, V = (V1, V2, ..., V...). n T is the set of output voltages of n distributed generation units, and I l =(I e1 ,I e2 ,…,I em T represents the set of currents for m lines; The dynamic relationships include: , , , Among them, V i V is the voltage of the distributed generation unit, i.e., the voltage of node i. j For V i The voltage of the adjacent j-th node, I i For the current of the distributed generation unit, L i For the inductance of the distributed generation unit, u i C is the control input for the distributed generation unit. i For the capacitors of the distributed generation unit. Let R be the set of neighbors of i in the distributed generation unit. i P is the load resistance. i For a constant power load, Iij L is the line current. ij R is the line inductance. ij Line resistance; The continuous-time state-space model is ,in, Let x be the time derivative of the state vector, a be the system matrix integrating physical parameters such as inductance, capacitance, and resistance, and b be the input matrix. , D L It is an n×n diagonal matrix, and is the inverse of the inductance matrix; It is an n x n matrix with all zeros, corresponding to the voltage V part in the state; It is an m x n matrix with all zeros, corresponding to the line current I. l part; The discrete-time physical state-space model is as follows: , .in, Let k be the state vector of the DC microgrid at time k. To control the input vector, Let be the discrete state transition matrix of the physical system. For the physical system control input matrix, Let Q be the process noise, and let Q be the process noise covariance matrix. For measurement vectors, For physical measurement matrix, For measuring noise, R is the measurement noise covariance matrix, and the measurement vector is selected from the current and voltage of each distributed generation unit and key line measurement point.
[0017] The core gating mechanisms of the LSTM layer include forget gate, input gate, and output gate. Among them, the forgetting gate is ; Input gate is ; Output gate is ; Where, x m Input data for the current moment. The hidden state is the state at the previous time step, and W and U are the weight matrices. For sigmoid activation function, The input weight matrix corresponds to the forget gate, input gate, and output gate, respectively. For the current input x... m Perform a linear transformation; The recursive weight matrix corresponds to the forget gate, input gate, and output gate, respectively, and represents the hidden state at the previous time step. Perform a linear transformation. These correspond to the bias vectors of the forget gate, input gate, and output gate, respectively. Transformer self-attention mechanisms include: ; in, h is the LSTM hidden state matrix. Here is the self-attention projection weight matrix. The key vector dimension is superimposed with position-encoded PE to inject sequence temporal information. It only represents queries, keys, and values.
[0018] The state equation in the ARIMA model is: , The observation equation in the ARIMA model is: ; in, Let ARIMA be the adjoint state vector at time k. Here is the ARIMA state transition matrix. The input matrix is white noise. This is the ARIMA observation matrix. It follows the principle of zero mean and variance. The distribution of white noise.
[0019] EM parameter optimization includes: ; ; Where M is the total number of observations, i.e., the number of time series samples; This is the state estimate. for Expectations for The variance of , t is the discrete time step, A is the system state transition matrix, and C is the observation matrix; The Kalman forecasting-correction forecasting phase is as follows: , ; The correction phase is as follows: , , , in, This is the prior state estimate at time k. For posterior state estimation, and These are the prior prediction error covariance and the posterior error covariance, respectively. For the new interest, For the new information covariance, This is the Kalman gain.
[0020] In a preferred embodiment of the present invention, the FDI attack model is as follows: , , in, f is the measured value under attack. k For the attack vector, Innovative sequences for attack models; KL divergence anomaly detection is as follows: ; Where p is the innovation sequence dimension and w is the sample window size. , These represent the distances to the j-th k-th nearest neighbors in normal and attack scenarios, respectively; when An attack alert is triggered when the threshold is set to δ. The confidence-trust consistency correction includes node self-confidence, neighbor trust, and robust estimate; where node self-confidence is: Neighbor trust level is The robust estimate is Where Υ1∈(0,1) are parameter tuning coefficients, and Λ1∈(0,1) are parameter tuning coefficients. Let represent the measurement data received by node i from neighbor j, and let Ni be the set of neighbors of node i.
[0021] In a preferred embodiment of the present invention, a state estimation system for a DC microgrid under FDI attack based on deep learning and Kalman filtering includes: The module acquires a state-space model of a DC microgrid, describes the power dynamics of distributed generation units and lines, and obtains a discrete-time state-space model. The analysis module is used to establish a TKF fusion framework. It extracts the spatiotemporal features of voltage or current time-series data from the microgrid using the Transformer-LSTM feature extraction module within the TKF fusion framework. The feature sequences of these spatiotemporal features are then converted into a Kalman-filter-compatible state space using an ARIMA model, generating Kalman-filter-compatible state and observation relationships. The EM algorithm iteratively optimizes the process noise covariance and observation noise covariance of the Kalman filter. Combined with the obtained discrete-time state-space model, the prediction-correction loop of the Kalman filter is executed, outputting preliminary state estimation results for the DC microgrid and a Kalman-filtered innovation sequence. The attack anomaly detection module performs FDI attack anomaly detection based on KL divergence. It uses the obtained Kalman filter innovation sequence to calculate KL divergence and identify FDI attacks in the measurement data. The output module performs attack compensation based on trust consistency correction and outputs robust estimation results, including: when an FDI attack is detected, the trust consistency correction strategy is used to perform weighted fusion of the state estimates of each node to compensate for the estimation bias caused by the attack and output the final robust estimation value.
[0022] The steps to implement a state estimation method for DC microgrids under FDI attack based on deep learning and Kalman filtering are described.
[0023] In a preferred embodiment of the present invention, a computer program product includes a computer program / instruction that, when executed by a processor, implements the steps of a method for state estimation of a DC microgrid under FDI attack based on deep learning and Kalman filtering.
[0024] This invention addresses the deficiencies in the technical background, and the beneficial technical effects of this invention are: A method, system, and program product for state estimation of DC microgrids under FDI attacks based on deep learning and Kalman filtering; it has anti-interference capabilities and can resist FDI attacks.
[0025] 1. By extracting time-series features through Transformer-LSTM and constructing the state space using ARIMA, the traditional DSE is freed from its dependence on an accurate physical model, making it suitable for complex DC microgrids with distributed energy integration.
[0026] 2. The EM algorithm optimizes the noise covariance and initial parameters of the Kalman filter, and combined with the noise-resistant feature extraction capability of Transformer-LSTM, it can still maintain high-precision estimation in noisy scenarios and has strong anti-interference ability.
[0027] 3. KL divergence anomaly detection can effectively identify FDI attacks, and the confidence-trust consensus mechanism can quickly mitigate the impact of attacks, avoid distortion of state estimation, and has excellent anti-attack performance.
[0028] 4. It can adapt to various operating modes of DC microgrids, such as droop control and secondary control, and is compatible with different types of DGUs and load components. It has high promotion value and wide adaptability. Attached Figure Description
[0029] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0030] Figure 1 This is a flowchart illustrating a preferred embodiment of the present invention; Figure 2 This is a schematic diagram of the system structure of a preferred embodiment of the present invention; Figure 3 This is the voltage tracking of the second power generation unit under attack in a preferred embodiment of the present invention; Figure 4 This is the voltage tracking of the third power generation unit under attack in a preferred embodiment of the present invention; Figure 5 This is the current tracking of the power generation unit under attack in a preferred embodiment of the present invention; Figure 6 This is the current tracking of the second power generation unit under attack in a preferred embodiment of the present invention. Detailed Implementation
[0031] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. These drawings are simplified schematic diagrams, which are only used to illustrate the basic structure of the present invention and therefore only show the components relevant to the present invention.
[0032] It should be noted that if directional indicators (such as up, down, bottom, top, etc.) are involved in the embodiments of the present invention, these directional indicators are only used to explain the relative positional relationship and movement of the components in a specific posture. If the specific posture changes, the directional indicators will also change accordingly. The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, features defined with "first" and "second" may explicitly or implicitly include one or more of that feature. Unless otherwise explicitly specified and limited, the terms "set," "connected," and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal connection of two components. For those skilled in the art, the specific meaning of the above terms in the present invention can be understood according to the specific circumstances.
[0033] Example 1: A method for state estimation of a DC microgrid under FDI attack based on deep learning and Kalman filtering, comprising: Step S1: Construct a state-space model of a DC microgrid to describe the power dynamics of distributed generation units and lines, and obtain a discrete-time state-space model.
[0034] Specifically, in step S1, the establishment of the state-space model of the DC microgrid includes: The state vector is defined as a set of output current, output voltage, and line current of the distributed generation unit, and the control input vector is the control signal of each distributed generation unit. Directed graphs are used to characterize the dynamic relationship between electrical nodes and lines, and a continuous-time state-space model is established to describe the dynamics of the system. The continuous-time state-space model is discretized using the forward Euler method to obtain the discrete-time state-space model.
[0035] Furthermore, in step S1, the continuous-time state-space model encompasses the system dynamics of the distributed generation units and lines, wherein the system dynamics include: The current dynamics of distributed generation units reflect inductive characteristics; The voltage dynamics of distributed generation units reflect the effects of capacitance, load resistance, and constant power load. The dynamic current of the line current in a distributed generation unit reflects the line impedance characteristics.
[0036] More specifically, the sampling time T during discretization must meet the system stability requirements and is usually taken as 0.01-0.1s. After discretization, the model needs to clearly define the state transition and the structure of the observation matrix to provide suitable input for subsequent Kalman filtering.
[0037] Step S2: Establish a TKF fusion framework. Extract the spatiotemporal features of the voltage or current time series data of the microgrid using the Trans-form-LSTM feature extraction module in the TKF fusion framework. Convert the feature sequence of the spatiotemporal features into a state space compatible with Kalman filtering using the ARIMA model, and generate state and observation relationships compatible with Kalman filtering. Iteratively optimize the process noise covariance and observation noise covariance of Kalman filtering using the EM algorithm. Combine the obtained discrete-time state space model, execute the prediction-correction loop of Kalman filtering, and output the preliminary state estimation results of the DC microgrid and the Kalman filtering innovation sequence.
[0038] Specifically, in step S2, the Transformer-LSTM feature extraction module includes an LSTM network and a Transformer self-attention mechanism; The Transformer-LSTM feature extraction module is constructed by sequentially connecting the measurement input layer, a four-layer LSTM temporal coding layer, a position coding layer, a Transformer multi-head self-attention layer, a feedforward network and residual normalization layer, and a feature mapping layer. Following this, an ARIMA state expansion layer and a Kalman prediction-correction layer are connected in sequence. The measurement input layer receives current and voltage data from n distributed generation units at each time step, resulting in a 2n-dimensional measurement. The four-layer LSTM outputs the hidden states at each time step. The Transformer calculates the dependencies across time steps and across measurement channels based on all hidden states. The feature mapping layer projects the fused results into a 2n-dimensional feature sequence corresponding one-to-one with each current and voltage channel.
[0039] The LSTM network is configured with 4 layers, and short-term temporal dependencies are captured through a gating mechanism. The Transformer self-attention mechanism calculates weights through Query / Key / Value, superimposes positional encoding to inject sequence order information, extracts spatiotemporal features, and arranges them according to time step encoding to obtain a feature sequence; Transformer-LSTM is trained using current and voltage time-series data from each distributed generation unit under normal operating conditions. The training data is obtained from a DC microgrid simulation platform and / or experimental data. Data containing FDI attacks is used for attack detection and robustness verification, but is not included in the basic training of the normal state predictor. The raw data is sequentially timestamped, imputed for missing values, and screened for abnormal spikes. The measurements are normalized to [-1, 1] using the minimum and maximum values of each channel in the training set.
[0040] The normalized continuous measurements are divided into sliding windows of length L=40 and step size 1. The measurement vector at each time step contains n-dimensional current and n-dimensional voltage, for a total of 2n dimensions. The sequence within the window is used as the model input, and the 2n-dimensional measurement at the next time step of the window is used as the supervision label. The mean square error of the one-step prediction is used as the training target.
[0041] ; in, Output the predicted vector for the model. As the true reference vector, This is the sum of squares of the errors in each dimension between the predicted vector and the true vector.
[0042] During training, the training and validation sets are divided in an 8:2 ratio. The AdamW optimizer is used with an initial learning rate of 0.001 and a batch size of 16, allowing for a maximum of 100 training epochs. Gradient pruning, cosine annealing learning rate scheduling, and early stopping are employed if the loss does not improve after 10 consecutive validation epochs. During inference, the output is inversely normalized and transformed into a 2n-dimensional feature sequence by the feature mapping layer, which is then input into the ARIMA state extension layer and the Kalman fusion layer.
[0043] The ARIMA model determines the order based on the characteristics of the feature sequence input to the Transformer-LSTM feature extraction module, transforms the feature sequence into a Kalman-compatible state space, and expands the state vector. Let the sliding window length be L, and the LSTM hidden dimension be... Then the input hidden state matrix and output fused feature matrix of the Transformer are respectively and The r-th column of F corresponds one-to-one with the r-th current or voltage measurement channel. ARIMA receives the univariate feature sequence formed by continuous windows column by column; after taking the last time step or weighting and aggregating by time dimension, a 2n-dimensional prediction is obtained, which is consistent with the physical measurement channel.
[0044] For each channel, the ADF test is first used to determine stationarity. When the sequence is non-stationary, differencing is performed step by step starting from d=0, and the difference order d that satisfies the stationarity requirement is usually determined within the range of 0 to 2. The candidate range of the autoregression order p and the moving average order q is determined based on the autocorrelation function and the partial autocorrelation function, with the minimum AIC or BIC as the main criterion, and the residuals are confirmed to be approximately white noise through the Ljung-Box test. p, d, and q can be determined separately for each channel, or a uniform combination of orders can be selected based on the prediction error of the validation set.
[0045] After performing difference and stationarity processing, ARIMA(p,d,q) is rewritten in adjoint state-space form: ; Physical state in step S1 Accompanying state with ARIMA Constitutes an augmented state . Characterizes the physical evolution determined by inductance, capacitance, load, and line parameters. Autoregressive evolution of characteristic sequences; Map ARIMA prediction information to physical state channels. The ARIMA observation information is mapped to the physical measurement channel. The augmented model is as follows: ; The process noise covariance, observation noise covariance, and initial state parameters of the Kalman algorithm are iteratively optimized using the EM algorithm until the parameter changes are less than 1e-5 and convergence is achieved, thus obtaining a preliminary state estimate.
[0046] Step S3: Perform FDI attack anomaly detection based on KL divergence. Calculate the KL divergence using the obtained Kalman filter innovation sequence to identify FDI attacks present in the measurement data. Specifically, the FDI attack model is used to quantify the logic by which attacks tamper with measurement and innovation sequences. The establishment of the FDI attack model includes: The post-attack measurement value is represented as the superposition of the normal measurement value and the attack vector. An attack identification variable is introduced to distinguish whether an attack has occurred. The destructive impact of FDI attacks on Kalman filter innovation sequences is analyzed. FDI attack detection is achieved based on KL divergence and k-NN. A nominal innovation distribution is established using attack-free data. The KL divergence between the Kalman filter innovation sequence and the nominal innovation distribution is calculated in real time. When the calculated KL divergence exceeds a preset threshold, an attack alarm is triggered.
[0047] Further, in step S3, the amplitude of the FDI attack vector is set to 5%-10% of the normal measurement value to mimic normal fluctuations and evade simple detection; the attack flag variable takes a value of 0 when there is no attack and 1 when there is an attack, and the attack period is usually selected in the middle of data collection. In step S3, the KL divergence is calculated using the k-NN method, with k value ranging from 5 to 10. The threshold needs to be determined by calculating the distribution using data without attack, and is usually set to the value corresponding to a false alarm rate of 5% to ensure a balance between the detection rate and the false alarm rate.
[0048] Step S4: Complete attack compensation based on trust consistency correction, and output robust estimation results, including: When an FDI attack is detected, a trust consistency correction strategy is adopted to weight and fuse the state estimates of each node to compensate for the estimation bias caused by the attack and output the final robust estimate.
[0049] Specifically, in step S4, a confidence-trust consensus mechanism is used to mitigate the impact of attacks. Each node calculates its self-confidence and neighbor trust, and the smaller the KL divergence, the higher the confidence.
[0050] Furthermore, the calculation of self-confidence requires the introduction of a tuning parameter, and the formula reflects the negative correlation between KL divergence and confidence. Neighbor confidence is calculated based on the distribution of neighbor information, and a tuning parameter is introduced to reflect the reliability of neighbor data. In weighted consistency, the sum of the weights of self-confidence and neighbor confidence is 1. Weighted fusion reduces the impact of nodes with large KL divergence (i.e., those that may be attacked), ensuring the robustness of the final estimate.
[0051] Example 2, building upon Example 1, presents a state estimation method for DC microgrids under FDI attacks based on deep learning and Kalman filtering. This method further includes a verification model, validating its effectiveness in DC microgrid scenarios under no-attack, FDI attack, and secondary control modes. Error indices are determined, and the parameters and detection thresholds of the TKF fusion framework are iteratively optimized based on the error to adapt to the dynamic changes of the DC microgrid. Specifically, the verification scenarios cover: verifying the basic estimation accuracy in a no-attack scenario, and verifying the detection speed and mitigation effect in an FDI attack scenario. The operating mode must include droop control and secondary control, with voltage estimation error and current estimation error as the verification indices, ensuring the applicability of the method in actual operation.
[0052] Example 3, based on Example 1 or Example 2, presents a method for state estimation of a DC microgrid under FDI attack based on deep learning and Kalman filtering.
[0053] The physical model of the DC microgrid includes: The state vector is: Where I = (I1, I2, ..., I nT is the set of output currents of n distributed generation units, V = (V1, V2, ..., V...). n T is the set of output voltages of n distributed generation units, and I l =(I e1 ,I e2 ,…,I em T is the set of currents for m lines.
[0054] The dynamic relationships include: , , , Among them, V i For the voltage of the distributed generation unit, I i For the current of the distributed generation unit, L i For the inductance of the distributed generation unit, u i C is the control input for the distributed generation unit. i For the capacitors of the distributed generation unit. Let R be the set of neighbors of i in the distributed generation unit. i P is the load resistance. i For a constant power load, I ij L is the line current. ij R is the line inductance. ij For line resistance, The continuous-time state-space model is as follows: The system matrix 'a' integrates physical parameters such as inductance, capacitance, and resistance. The input matrix is: , , which is the inverse of the inductance matrix.
[0055] The discrete-time physical state-space model is as follows: .in, Let k be the state vector of the DC microgrid at time k. To control the input vector, Let be the discrete state transition matrix of the physical system. For the physical system control input matrix, Let Q be the process noise, and let Q be the process noise covariance matrix. For measurement vectors, For physical measurement matrix, For measuring noise, R is the measurement noise covariance matrix, and the measurement vector is selected from the current and voltage of each distributed generation unit and key line measurement point.
[0056] The forget gate, input gate, output gate, candidate memory unit, memory unit, and hidden state of the LSTM layer are as follows: , , ; , , ; in, Enter the current time step. The hidden state of the previous time step. This represents the memory unit of the previous time step, σ is the sigmoid activation function, and ⊙ represents element-wise multiplication; These are the input weight matrices for each gate. These are the cyclic weight matrices for each gate. This is the bias vector.
[0057] The aforementioned weight matrix was obtained by learning from the sliding window data under normal operating conditions through backpropagation over time. Initialize using the Xavier method. Orthogonal initialization is used, with biases initialized to zero or a small constant. The weights are iteratively updated using AdamW, targeting the mean squared error of the previous prediction step, and gradient pruning, early stopping on the validation set, and learning rate scheduling are employed to suppress overfitting. After training, the weights are fixed for online inference, or retrained with a small learning rate using newly added normal operating condition samples.
[0058] The Transformer self-attention mechanism includes: ; in, h is the LSTM hidden state matrix. Here is the self-attention projection weight matrix. The key vector dimension is superimposed with position-encoded PE to inject sequence temporal information. It only represents queries, keys, and values.
[0059] End-to-end joint training is performed with the LSTM layer and feature mapping layer. The 2n-dimensional current and voltage prediction errors at the next time step constitute a unified mean square error loss, and the gradient is backpropagated through self-attention operation to... And is updated synchronously by AdamW; the validation set loss is used for model selection and early stopping, so that the three projection matrices learn the time steps and measurement channel correlations that contribute significantly to state prediction.
[0060] The state equation of ARIMA(p,d,q) after adjoint form transformation is: The observation equation is: .in, Let ARIMA be the adjoint state vector at time k. Here is the ARIMA state transition matrix. The input matrix is white noise. This is the ARIMA observation matrix. It is zero-mean white noise.
[0061] Transformer output Its 2n columns correspond to n current channels and n voltage channels respectively; ARIMA receives continuous-time characteristic sequences column by column. The difference order d is determined by the ADF stationarity test, and the autoregression order p and the moving average order q are based on the candidate range given by the autocorrelation function and the partial autocorrelation function, with the minimum AIC or BIC as the main criterion, and the residuals are confirmed to be approximately white noise through the Ljung-Box test.
[0062] Physical state and ARIMA adjoint state according to To augment, and The state channel and measurement channel mappings are completed separately; the resulting augmented state transition matrix and augmented observation matrix are used for subsequent Kalman prediction-correction.
[0063] The EM parameter optimization includes: ; ; Where M is the total number of observations, This is the state estimate. for Expectations for The variance.
[0064] The Kalman prediction-correction prediction stage and the innovation calculation and correction stage are as follows: ; ; ; in, This is the prior state estimate at time k. For the posterior state estimate at time k, For the prior prediction error covariance, For the posterior error covariance; This is the physical state transition matrix. To control the input matrix, Let I be the physical measurement matrix, Q and R be the process noise covariance and measurement noise covariance, respectively, and I be the identity matrix. For the new interest, For the new information covariance, Let be the Kalman gain. Let Σ represent the Kalman error covariance, and use it in relation to the constant power load. Distinguish between them.
[0065] Specifically, the FDI attack model is as follows: , ,in, f is the measured value under attack. k For the attack vector, Innovative sequences for attack models.
[0066] Specifically, the KL divergence anomaly detection is as follows: Where p is the innovation sequence dimension and w is the sample window size. , These represent the distances to the j-th k-th nearest neighbors in normal and attack scenarios, respectively; when An attack alert is triggered when the time is right, where δ is a preset threshold.
[0067] Specifically, the confidence-trust consistency correction includes node self-confidence, neighbor trust, and robust estimate; where node self-confidence is: Neighbor trust level is The robust estimate is Where Υ1∈(0,1) are parameter tuning coefficients, and Λ1∈(0,1) are parameter tuning coefficients. For the measurement data received by node i from neighbor j, N i Let i be the set of neighbors of node i.
[0068] The root mean square error (RMSE) is used as the core error metric, and the formula is as follows: , Where N is the total number of data points, x k This represents the actual state. To robustly estimate the state.
[0069] Example 4: A state estimation system for a DC microgrid under FDI attack based on deep learning and Kalman filtering, comprising: The module acquires a state-space model of a DC microgrid, describes the power dynamics of distributed generation units and lines, and obtains a discrete-time state-space model.
[0070] Specifically, using the DGU output current, voltage, and line current as state vectors, a continuous-time state-space equation is established based on circuit laws. The forward Euler method is used for discretization (with a fixed sampling time) to obtain a discrete model containing equations for state transition (associating the state at the previous moment, control input, and process noise) and measurement (associating the current state, noise, and current / voltage measurements).
[0071] The analysis module is used to establish a TKF fusion framework. It extracts the spatiotemporal features of voltage or current time-series data from the microgrid using the Transformer-LSTM feature extraction module within the TKF fusion framework. The feature sequences of these spatiotemporal features are then converted into a Kalman-filter-compatible state space using an ARIMA model, generating Kalman-filter-compatible state and observation relationships. The EM algorithm iteratively optimizes the process noise covariance and observation noise covariance of the Kalman filter. Combined with the obtained discrete-time state-space model, the prediction-correction loop of the Kalman filter is executed, outputting preliminary state estimation results for the DC microgrid and a Kalman-filtered innovation sequence.
[0072] Specifically, a closed-loop framework is constructed: a Transformer-LSTM dual subnet (LSTM captures short-term time dependencies, and Transformer compensates for long-term dependencies) is used to extract voltage / current time-series features; an ARIMA model is used to describe the feature patterns and translate them into a Kalman-compatible state-space form; the state is estimated through a Kalman filter "prediction-correction" loop, and the EM algorithm iteratively optimizes the filter parameters (noise covariance, initial state, etc.) until convergence.
[0073] The attack anomaly detection module performs FDI attack anomaly detection based on KL divergence. It uses the obtained Kalman filter innovation sequence to calculate KL divergence and identify FDI attacks in the measurement data.
[0074] Specifically, an FDI attack is defined, and the KL divergence between the attacked target and the normal Kalman innovation distribution is estimated using the k-nearest neighbor method. An alarm is triggered if the divergence exceeds a preset threshold (based on the false alarm rate).
[0075] The output module performs attack compensation based on trust consistency correction and outputs robust estimation results, including: when an FDI attack is detected, the trust consistency correction strategy is used to perform weighted fusion of the state estimates of each node to compensate for the estimation bias caused by the attack and output the final robust estimation value.
[0076] Specifically, nodes calculate their self-confidence (self-measurement reliability) and neighbor trust based on KL divergence, and then weight and fuse the local and neighbor state estimation results according to this score to reduce the impact of attacked (low-trust) data.
[0077] The adaptation module is used to collect voltage and current time-series data in real time during the operation of the DC microgrid, input the collected data into the TKF fusion framework, output the initial dynamic state estimation results, determine the error index, and continuously iterate and optimize the TKF parameters and detection thresholds based on the error to adapt to the dynamic changes of the power grid.
[0078] The steps to implement a state estimation method for DC microgrids under FDI attack based on deep learning and Kalman filtering are described.
[0079] Example 5: A computer program product, including a computer program / instructions, which, when executed by a processor, implements the steps of a method for state estimation of a DC microgrid under FDI attack based on deep learning and Kalman filtering.
[0080] Working principle: This invention provides a method, system, and program product for state estimation of DC microgrids under FDI attacks based on deep learning and Kalman filtering; it has anti-interference capabilities and can resist FDI attacks.
[0081] First, a continuous-discrete state-space model of a DC microgrid is constructed to describe the current and voltage dynamics of distributed generation units and lines. Next, a Transformer-Kalman Filtering fusion framework is designed, using Transformer-LSTM to extract spatiotemporal features of time-series data, ARIMA to construct a Kalman-compatible state space, and the EM algorithm to optimize filtering parameters, achieving preliminary state estimation. Then, an FDI attack model is established, using KL divergence and k-NN for attack detection, and a confidence-trust consensus mechanism to mitigate the impact of attacks. Finally, the effectiveness of the model is verified in a scenario with FDI attacks in the secondary control mode. This invention can improve the robustness and accuracy of DC microgrid state estimation while reducing the interference of FDI attacks on the system.
[0082] This invention extracts temporal features using Transformer-LSTM and constructs the state space using ARIMA, eliminating the dependence of traditional DSE on precise physical models and making it suitable for complex DC microgrids with distributed energy integration. The EM algorithm optimizes the noise covariance and initial parameters of the Kalman filter, and combined with the noise-resistant feature extraction capabilities of Transformer-LSTM, it maintains high-accuracy estimation even in noisy environments, demonstrating strong anti-interference capabilities. KL divergence anomaly detection effectively identifies FDI attacks, and the confidence-trust consensus mechanism quickly mitigates the impact of attacks, avoiding state estimation distortion and exhibiting excellent anti-attack performance. It is adaptable to various operating modes of DC microgrids, such as droop control and secondary control, and is compatible with different types of DGUs and load components, making it highly valuable for widespread application and with broad applicability.
[0083] like Figure 1 , Figure 2 The diagrams shown are a flowchart and a system architecture diagram. Figure 3 , Figure 4 The figures show the dynamic variation curves of the actual voltage and estimated voltage of distributed generation unit two and distributed generation unit three under attack conditions, respectively, using the method of this invention. Figure 3 and Figure 4 The study concludes that, under attack conditions, the estimates of distributed generation units two and three only fluctuate slightly in the initial stage, then quickly coincide with the actual voltage curve, maintaining consistent tracking performance throughout. This demonstrates the rapid response capability of the method to voltage states, quickly converging to the actual value even in the initial dynamic stage, effectively improving the reliability of DC microgrid state estimation. Figure 5 , Figure 6 The figures show the dynamic curves of the actual and estimated currents of distributed generation unit 1 and distributed generation unit 2 under attack conditions. Figure 5 and Figure 6 The results show that, under attack conditions, the estimated current curves of distributed generation unit 1 and distributed generation unit 2 closely match the actual current curves, and the deviation between the two can converge to a very small range within the entire 500 time steps, indicating that the method of this invention has excellent accuracy in current state estimation. Compared with the traditional Kalman filtering method, the estimation results have better fit and stronger stability.
[0084] The above specific embodiments are specific support for the concept proposed in this invention, and should not be used to limit the scope of protection of this invention. Any equivalent changes or modifications made on the basis of this technical solution in accordance with the technical concept proposed in this invention shall still fall within the scope of protection of this invention.
Claims
1. A method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering, characterized in that, include: Step S1: Construct a state-space model of a DC microgrid to describe the power dynamics of distributed generation units and lines, and obtain a discrete-time state-space model. Step S2: Establish a TKF fusion framework. Extract the spatiotemporal features of the voltage or current time-series data of the microgrid using the Transformer-LSTM feature extraction module within the TKF fusion framework. Transform the feature sequence of the spatiotemporal features into a Kalman-filter-compatible state space using the ARIMA model, generating Kalman-filter-compatible state and observation relationships. Iteratively optimize the process noise covariance and observation noise covariance of the Kalman filter using the EM algorithm. Combined with the obtained discrete-time state-space model, execute the Kalman filter prediction-correction loop to output the preliminary state estimation results of the DC microgrid and the Kalman filter innovation sequence. Step S3: Perform FDI attack anomaly detection based on KL divergence. Calculate the KL divergence using the obtained Kalman filter innovation sequence to identify FDI attacks present in the measurement data. Step S4: Complete attack compensation based on trust consistency correction, and output robust estimation results, including: When an FDI attack is detected, a trust consistency correction strategy is adopted to weight and fuse the state estimates of each node to compensate for the estimation bias caused by the attack, and output the final robust estimate as the robust estimation result.
2. The method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering according to claim 1, characterized in that: In step S1, the establishment of the state-space model of the DC microgrid includes: The state vector is defined as a set of output current, output voltage, and line current of the distributed generation unit, and the control input vector is the control signal of each distributed generation unit. Directed graphs are used to depict the dynamic relationship between electrical nodes and lines, i.e. the power dynamics between distributed generation units and lines, and as the system dynamics, a continuous-time state-space model is established to describe the system dynamics. The continuous-time state-space model is discretized using the forward Euler method to obtain the discrete-time state-space model.
3. The method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering according to claim 2, characterized in that: In step S1, the continuous-time state-space model encompasses the system dynamics, which include: The current dynamics of distributed generation units reflect inductive characteristics; The voltage dynamics of distributed generation units reflect the effects of capacitance, load resistance, and constant power load. The dynamic current of the line current in a distributed generation unit reflects the line impedance characteristics.
4. The method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering according to claim 1, characterized in that: In step S2, the Transformer-LSTM feature extraction module includes an LSTM network and a Transformer self-attention mechanism; The LSTM network is configured with 4 layers and uses a gating mechanism to capture short-term temporal dependencies. The Transformer self-attention mechanism calculates weights through Query / Key / Value, superimposes positional encoding to inject sequence order information, extracts spatiotemporal features, and arranges them according to time step encoding to obtain a feature sequence; The ARIMA model determines its order based on the characteristics of the feature sequence input to the Transformer-LSTM feature extraction module, converts the feature sequence into a Kalman-compatible state space, and expands the state vector. The process noise covariance, observation noise covariance, and initial state parameters of the Kalman algorithm are iteratively optimized using the EM algorithm until the parameter changes are less than 1e-5 and convergence is achieved, thus obtaining a preliminary state estimate.
5. The method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering according to claim 1, characterized in that: The FDI attack model is used to quantify the logic by which attacks tamper with measurement and innovation sequences. The establishment of the FDI attack model includes: The post-attack measurement value is represented as the superposition of the normal measurement value and the attack vector. An attack identification variable is introduced to distinguish whether an attack has occurred. The destructive impact of FDI attacks on Kalman filter innovation sequences is analyzed. FDI attack detection is achieved based on KL divergence and k-NN. A nominal innovation distribution is established using attack-free data. The KL divergence between the Kalman filter innovation sequence and the nominal innovation distribution is calculated in real time. When the calculated KL divergence exceeds a preset threshold, an attack alarm is triggered. In step S4, a confidence-trust consensus mechanism is used to mitigate the impact of attacks. Each node calculates its self-confidence and neighbor trust, and the smaller the KL divergence, the higher the confidence.
6. The method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering according to claim 5, characterized in that: It also includes a verification model, which verifies the effectiveness of the model in DC microgrid scenarios under no-attack, FDI attack, and secondary control modes, determines error indicators, and continuously iterates and optimizes the parameters and detection thresholds of the TKF fusion framework based on the error to adapt to the dynamic changes of DC microgrids.
7. The method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering according to claim 6, characterized in that: The physical model of a DC microgrid includes: The state vector is: Where I = (I1, I2, ..., I n T is the set of output currents of n distributed generation units, V = (V1, V2, ..., V...). n T is the set of output voltages of n distributed generation units, and I l =(I e1 ,I e2 ,…,I em T represents the set of currents for m lines; The dynamic relationships include: , , , Among them, V i V is the voltage of the distributed generation unit, i.e., the voltage of node i. j For V i The voltage of the adjacent j-th node, I i L represents the current of the distributed generation unit. i For the inductance of the distributed generation unit, u i C is the control input for the distributed generation unit. i For the capacitors of the distributed generation unit. Let R be the set of neighbors of i in the distributed generation unit. i P is the load resistance. i For a constant power load, I ij L is the line current. ij R is the line inductance. ij Line resistance; The continuous-time state-space model is ,in, Let x be the time derivative of the state vector, a be the system matrix integrating physical parameters such as inductance, capacitance, and resistance, and b be the input matrix. , D L It is an n×n diagonal matrix, and is the inverse of the inductance matrix; It is an n x n matrix with all zeros, corresponding to the voltage V part in the state; It is an m x n matrix with all zeros, corresponding to the line current I. l part; The discrete-time physical state-space model is as follows: , ; in, Let k be the state vector of the DC microgrid at time k. To control the input vector, Let be the discrete state transition matrix of the physical system. For the physical system control input matrix, Let Q be the process noise, and let Q be the process noise covariance matrix. For measurement vectors, For physical measurement matrix, For measuring noise, R is the measurement noise covariance matrix, and the measurement vector is selected from the current and voltage of each distributed generation unit and key line measurement point; The core gating mechanisms of the LSTM layer include forget gate, input gate, and output gate. Among them, the forgetting gate is ; Input gate is ; Output gate is ; Where, x m Input data for the current moment. The hidden state is the state at the previous time step, and W and U are the weight matrices. For sigmoid activation function, The input weight matrix corresponds to the forget gate, input gate, and output gate, respectively. For the current input x... m Perform a linear transformation; The recursive weight matrix corresponds to the forget gate, input gate, and output gate, respectively, and represents the hidden state at the previous time step. Perform a linear transformation. These correspond to the bias vectors of the forget gate, input gate, and output gate, respectively. Transformer self-attention mechanisms include: ; in, h is the LSTM hidden state matrix. Here is the self-attention projection weight matrix. The key vector dimension is superimposed with position-encoded PE to inject sequence temporal information; This only represents the query, key, and value; The state equation in the ARIMA model is: , The observation equation in the ARIMA model is: ; in, Let ARIMA be the adjoint state vector at time k. Here is the ARIMA state transition matrix. The input matrix is white noise. This is the ARIMA observation matrix. It follows the principle of zero mean and variance. The distribution of white noise; EM parameter optimization includes: ; ; Where M is the total number of observations, i.e., the number of time series samples; This is the state estimate. for Expectations for The variance of , t is the discrete time step, A is the system state transition matrix, and C is the observation matrix; The Kalman forecasting-correction forecasting phase is as follows: , ; The correction phase is as follows: , , , in, This is the prior state estimate at time k. For posterior state estimation, and These are the prior prediction error covariance and the posterior error covariance, respectively. For the new interest, For the new information covariance, This is the Kalman gain.
8. The method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering according to claim 7, characterized in that: The FDI attack model is as follows: , , in, f is the measured value under attack. k For the attack vector, Innovative sequences for attack models; KL divergence anomaly detection is as follows: ; Where p is the innovation sequence dimension and w is the sample window size. , These represent the distances to the j-th k-th nearest neighbors in normal and attack scenarios, respectively; when An attack alert is triggered when the time is right, where δ is a preset threshold. The confidence-trust consistency correction includes node self-confidence, neighbor trust, and robust estimate; where node self-confidence is: Neighbor trust level is The robust estimate is Where Υ1∈(0,1) are parameter tuning coefficients, and Λ1∈(0,1) are parameter tuning coefficients. For the measurement data received by node i from neighbor j, N i Let i be the set of neighbors of node i.
9. A state estimation system for a DC microgrid under FDI attack based on deep learning and Kalman filtering, characterized in that, include: The module acquires a state-space model of a DC microgrid, describes the power dynamics of distributed generation units and lines, and obtains a discrete-time state-space model. The analysis module is used to establish a TKF fusion framework. It extracts the spatiotemporal features of voltage or current time-series data from the microgrid using the Transformer-LSTM feature extraction module within the TKF fusion framework. The feature sequences of these spatiotemporal features are then converted into a Kalman-filter-compatible state space using an ARIMA model, generating Kalman-filter-compatible state and observation relationships. The EM algorithm iteratively optimizes the process noise covariance and observation noise covariance of the Kalman filter. Combined with the obtained discrete-time state-space model, the prediction-correction loop of the Kalman filter is executed, outputting preliminary state estimation results for the DC microgrid and a Kalman-filtered innovation sequence. The attack anomaly detection module performs FDI attack anomaly detection based on KL divergence. It uses the obtained Kalman filter innovation sequence to calculate KL divergence and identify FDI attacks in the measurement data. The output module completes attack compensation based on trust consistency correction and outputs robust estimation results, including: when an FDI attack is detected, the trust consistency correction strategy is used to perform weighted fusion of the state estimates of each node to compensate for the estimation bias caused by the attack and output the final robust estimation value. The steps of implementing the state estimation method for DC microgrids based on deep learning and Kalman filtering under FDI attack as described in any one of claims 1-8.
10. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps of the method for state estimation of DC microgrids under FDI attack based on deep learning and Kalman filtering as described in any of claims 1-8.
Citation Information
Patent Citations
Intermediate variable-based estimation method of DC micro-grid T-S fuzzy system under FDI attack
CN119182111A
Direct-current micro-grid power buffer safety control method and device aiming at FDI attack
CN121440520A
