# A Consensus-Based Distributed Two-Layer Control Strategy with Predictive Compensation for Islanded Microgrid CPS against DoS Attack

Authors: Xinrui Liu; Min Hou; Jianjun Yang; Yufei Sun
Journal: International Transactions on Electrical Energy Systems
 (2022)

---

## Abstract

Summary.Aiming at the problems of insufficient scalability and slow response speed of the traditional three-layer control structure based on the time scale, this study proposes a distributed two-layer control structure. The primary control uses traditional power-frequency droop control, and the second-level control adopts a consensus protocol to simultaneously achieve the goals of frequency synchronization, frequency non-difference, and power optimization in a distributed manner, which can effectively improve the performance of microgrid frequency adjustment and power optimization. The cyber layer of the AC microgrid cyber-physical system (CPS) is extremely vulnerable to denial-of-service (DoS) attacks, resulting in the inability to achieve control objectives. For this reason, this paper designs a consensus algorithm based on event-triggered and a predictive compensation control link that combines empirical mode decomposition (EMD) and extreme learning machine (ELM) on the basis of the two-layer control structure. Finally, a 4-node islanded microgrid simulation example is used to verify the effectiveness of the proposed strategy. The simulation results show that the two-layer control strategy can achieve microgrid frequency recovery and power optimization while effectively responding to different degrees of DoS attacks.


---

## Body

## 1. Introduction

The microgrid is one of the most important ways to connect distributed energy to the grid, and it usually works in two modes: islanded and grid-connected mode. In view of the complexity of the microgrid structure and the diversity of control objectives, hierarchical control is usually used to achieve stable and optimized operation of the microgrid. At present, the most widely used is the three-layer control structure based on time scale. [1, 2] Among them, the first level of control directly acts on distributed generators (DGs), its action time is at the level of seconds. The second layer is the secondary adjustment layer, which focuses on the dynamic operation control of the microgrid, its action time has risen from the second level to the minute level. The third layer is the optimization management layer, which has the longest role time and is mainly used to realize power flow control and optimal scheduling. However, due to the long control time and slow response speed of the third layer, before the arrival of the third layer control command, the actual operation of the system may deviate from the expected optimal state due to the inevitable power disturbance in the microgrid, resulting in the reduction of the execution efficiency of power optimization and the deterioration of the economy of the microgrid. [3] Therefore, if the control structure is reduced to two layers, it will improve the operation efficiency of the microgrid.The flexibility, reliability, and scalability of the distributed control mode are stronger than those of the centralized control mode. Therefore, the distributed control mode [4, 5] is generally used in microgrid. In particular, the multi-agent control method [6, 7] based on the consensus protocol is widely used to solve the problems of voltage regulation, frequency regulation, and optimization [8–11] in hierarchical control due to its simple structure, flexible control, and only sparse communication. With the continuous development of the intelligent construction of the power grid, the microgrid gradually has the relevant characteristics of the cyber-physical system (CPS). [6, 12] The information layer in the microgrid CPS structure usually involves more control decisions and communication processes, and the use of communication data inevitably leads to communication problems such as delays, packet loss, and communication failures [13, 14]. The traditional three-layer control structure can no longer meet the security requirements of the equipment, and the network security of the microgrid CPS is worth further exploration.In References [15, 16], a smart energy dispatching method based on distributed economic cooperative predictive control is proposed. In References [17–19], a pilot distributed follower decentralized control strategy for islanded microgrids is proposed, which realizes economic dispatch while ensuring voltage quality and frequency synchronization. However, the above literature are only based on the structure of the physical layer and do not consider the security of the information layer, which is extremely vulnerable to malicious attacks on the network. [20–22] References [6, 12] construct an information-physical collaborative hierarchical control structure and solves random communication problems by designing corresponding observers, controllers, and predictive compensators. In References [23, 24], aiming at the insufficient tolerance of MG to DoS attacks when edge routers in microgrid suffer from DoS attacks, a consensus-based secondary frequency controller with dynamic P-f droop control is proposed and its stability is analyzed. References [25, 26] study the realization of cyber-physical system security and stability control issues in complex networks under non-periodic DoS attacks. However, the above-mentioned literature only studies the network attack on the secondary control level, but does not propose an effective solution to the network attack for a microgrid with third control targets. A fully distributed microgrid frequency recovery and power optimization structure capable of responding to network attacks have not yet appeared. Therefore this paper proposes a distributed two-layer control structure that combines droop control and consensus algorithm in order to improve the performance of microgrid frequency adjustment and power optimization under the consideration of the network being attacked by DoS. The main contributions are as follows:(1)
The distributed control structure designed in this study can overcome the shortcomings of centralized control and transfer the power optimization control to the second layer. While the frequency is restored to the nominal value, the incremental cost(IC) can be consistent, which can effectively improve the optimization operation efficiency of the microgrid.(2)
Aiming at the DoS attacks that occur on the communication link of the cyber layer, the improved consensus algorithm based on event-triggered and predictive compensation that combines EMD and ELM can effectively respond to different degrees of DoS attacks.


## 2. Microgrid System Modeling

### 2.1. Multi-Agents Distributed Model

For a MG containingn DGs, DGs are regarded as nodes in the agent communication network, and the communication topology can be represented by an undirected graph G. In graph G, the adjacency matrix A=aijn×n is usually used to describe the relationship between nodes, whereaij represents the connection weight between node i and node j, and n is the number of nodes. If the j-th node has an edge pointing to the i-th node, thenaij>0, i≠j, otherwise aij=0, the diagonal element aii=0.For a distributed multi-agents control system withn agents, due to the use of distributed control laws, the change of each agent’s state depends on its own current state and the current state of its neighboring agents, which can be expressed for(1)uit=−∑j∈Niaijxit−xjt.Written in matrix form as(2)X˙=UU=−LX.Lemma 1.
Assuming that the multi-agents systems are undirected and connected, then its corresponding Laplacian matrix must be a real symmetric matrix, the aforementioned protocol can achieve the average consistency of the system, namely [23],(3)x1∞=x2∞=⋯=xn∞≈∑i=1nxi0n.


### 2.2. Cost Function Model

The operating cost of the i-th DGs can be described as follows:(4)CiPi=aiPi2+biPi+cii=1,…,n.The goal of economic dispatch of the islanded microgrid is to minimize the operating cost, namely,(5)Ctotal=min∑i=1nCiPi.The generated power of each distributed power source must meet the power balance constraint conditions:(6)∑i=1nPi=∑j=1lPDj=PD.The DG generation power should also meet the following constraints:(7)Pi,min≤Pi≤Pi,maxi=1,…,n.Based on the Lagrangian multiplier method and the equal incremental rate theory, the target formula of economic dispatch is transformed into an incremental factor synchronization control target, which includes(8)λiPi=C˙iPi=2aiPi+bi=λ∗,Pi,min<Pi<Pi,maxλiPi=C˙iPi=2aiPinmin+bi,Pi=Pi,minλiPi=C˙iPi=2aiPi,max+bi,Pi=Pi,max.Eq.(8) explains that if Pi is within the allowable output range, when the IC of all DG is equal to the optimal IC, the total power generation cost of the system is minimum. When Pi reaches the upper or lower limit of capacity, DGi should run on its bounded value, and the rest of the DGs should continue to run according to the above economic dispatch rules. The optimal IC can be calculated as:(9)λ∗=PD+∑i=1nbi/2ai∑i=1n1/2ai.


## 2.1. Multi-Agents Distributed Model

For a MG containingn DGs, DGs are regarded as nodes in the agent communication network, and the communication topology can be represented by an undirected graph G. In graph G, the adjacency matrix A=aijn×n is usually used to describe the relationship between nodes, whereaij represents the connection weight between node i and node j, and n is the number of nodes. If the j-th node has an edge pointing to the i-th node, thenaij>0, i≠j, otherwise aij=0, the diagonal element aii=0.For a distributed multi-agents control system withn agents, due to the use of distributed control laws, the change of each agent’s state depends on its own current state and the current state of its neighboring agents, which can be expressed for(1)uit=−∑j∈Niaijxit−xjt.Written in matrix form as(2)X˙=UU=−LX.Lemma 1.
Assuming that the multi-agents systems are undirected and connected, then its corresponding Laplacian matrix must be a real symmetric matrix, the aforementioned protocol can achieve the average consistency of the system, namely [23],(3)x1∞=x2∞=⋯=xn∞≈∑i=1nxi0n.


## 2.2. Cost Function Model

The operating cost of the i-th DGs can be described as follows:(4)CiPi=aiPi2+biPi+cii=1,…,n.The goal of economic dispatch of the islanded microgrid is to minimize the operating cost, namely,(5)Ctotal=min∑i=1nCiPi.The generated power of each distributed power source must meet the power balance constraint conditions:(6)∑i=1nPi=∑j=1lPDj=PD.The DG generation power should also meet the following constraints:(7)Pi,min≤Pi≤Pi,maxi=1,…,n.Based on the Lagrangian multiplier method and the equal incremental rate theory, the target formula of economic dispatch is transformed into an incremental factor synchronization control target, which includes(8)λiPi=C˙iPi=2aiPi+bi=λ∗,Pi,min<Pi<Pi,maxλiPi=C˙iPi=2aiPinmin+bi,Pi=Pi,minλiPi=C˙iPi=2aiPi,max+bi,Pi=Pi,max.Eq.(8) explains that if Pi is within the allowable output range, when the IC of all DG is equal to the optimal IC, the total power generation cost of the system is minimum. When Pi reaches the upper or lower limit of capacity, DGi should run on its bounded value, and the rest of the DGs should continue to run according to the above economic dispatch rules. The optimal IC can be calculated as:(9)λ∗=PD+∑i=1nbi/2ai∑i=1n1/2ai.


## 3. Two-Level Distributed Control Strategy

### 3.1. Control Structure and Control Objectives

On the basis of P-f droop control, a consistent control strategy based on droop control is proposed to solve the problem of fully distributed data collection. Because there is no leader DG, dependence on the central controller under the centralized control structure is avoided. In this paper, a two-way communication network is adopted. Regarding each DG as an agent, the local controller of each agent exchanges IC information with the local controllers of its neighboring agents. Based on the transmission of IC information, the proposed consistency control strategy can simultaneously achieve frequency adjustment and optimal economic operation.The hierarchical control structure constructed in this article is different from the traditional three-layer structure. This article only needs to establish a two-layer structure. At the second layer, both power optimization and frequency recovery are realized, aiming to greatly shorten the optimization operation time, and significantly improve the stability and optimization operation efficiency of the microgrid. Taking the i-th DG as an example, the hierarchical control architecture with CPS characteristics is shown in Figure1.Figure 1
The hierarchical control architecture diagram of the i-th DG.The control objectives of this microgrid system can be summarized as follows:Goal 1: Frequency synchronization.(10)limt⟶∞fi−fj=0,∀i,j∈Ω.Goal 2: Frequency error-free.(11)limt⟶∞fi−fMGref=0,∀i∈Ω.Goal 3: Consistent incremental cost.(12)limt⟶∞λiPi−λjPj=0,∀i,j∈Ω.In addition, the system also needs to meet the power balance constraints and the upper and lower limits of DG generation power, which have been explained in the previous section and will not be explained here.


### 3.2. Primary Control Strategy

The primary control considers the use of traditional droop control to achieve frequency stability, which is given as follows:(13)fi=fMGref−miPi−Piref.For a microgrid composed of multiple DGs in parallel, the frequency of each DG is equal, that is,fi is equal. However, droop control is a differential control. Therefore, to make the frequency of each DG equal to the system frequency, a common method is to add frequency compensation to restorefi to fMGref.


### 3.3. Secondary Frequency Modulation and Power Optimization Control Strategy

The primary control only acts on the controllable DG unit of the physical layer, and the second layer control has been upgraded from the physical layer to the cyber layer, and requires sparse communication between DGs to achieve information exchange and coordinated control. Since the control scheme adopts a ring communication network to transmit the IC information of DGs, it can eliminate the requirement of Leader DG, reduce the information exchange between DGs, and improve efficiency. Since reactive power does not incur any costs, there is no need to discuss reactive power sharing schemes.For the goal of frequency error-free control, it is realized by adding a PI controller, and the compensation amount is calculated according to the following formula:(14)δf=kP,ifMGref−fi+kI,i∫fMGref−fidt.Aiming at the realization of the power optimization goal, without considering the DG capacity constraints, the control equation is designed as follows [21]:(15)Piref=∑j=1naijλj−λi−bi2ai,(16)fi=fMGref−miPi−Piref+kP,ifMGref−fi+kI,i∫fMGref−fidt.The IC information is selected as the consistency variable, and the local controller of DGi updates the reference powerPiref according to (15). In addition, the system frequency is stabilized based on (16). That is to say, the proposed method can update the output power reference value according to the neighboring IC information, and realize economic operation and frequency recovery, which is convenient to implement and simplifies the control loop.The process of equations (15) and (16) to achieve frequency recovery and power optimization is as follows.The matrix form of (15) and (16) is expressed as follows:(17)Pref=12a−1Αλ−λ−b,(18)f=fMGref−MP−Pref+KpfMGref−f+KIΔ,where Pref=P1ref,P2ref,…,PnrefTa=diaga1,a2,a3,⋯anλ=λ1,λ2,⋯,λnTb=b1,b2,…,bnTKp=diagkp,1,kp,2,…,kp,nKI=diagkI,1,kI,2,…,nkI,nf=f1,f2,…,fnT, fMGref=fMGref1n, P=P1,P2,…,PnT, Δ=∫fMGref−fdt.The design of the adjacency matrix in this paper is as follows:(19)A=01⋯01101⋯0010⋯0⋯⋯⋯⋯110⋯1⋯n×n.According to (17) and (18), (20) can be obtained as follows:(20)Lλ=2aM−1E+KPΔf+KIΔ,where Δf=fMGref−f.The Laplacian matrix of the communication graph has the following form:(21)L=2−1⋯0−1−12−1⋯00−12⋯0⋯⋯⋯⋯−1−10⋯−12n×n.According to (20), (22) can be obtained as follows:(22)−∑j=1naijλi−λj=κiΔfi+ζi∫Δfidt,where Δfi=fMGref−fi, κi=−2ai/mi1+kp,i, and ζi=−2aikI,i/mi.The left side of (22) denotes the consistency control, which can be defined as follows:(23)uit=−∑j=1naijλi−λj.Taking the IC as a consistency variable, the state of each variable will eventually be consistent under the control of the consistency algorithm, that is:λi=λj. Thus,(24)κiΔfi+ζi∫Δfidt=0.From the expressions ofκi andζi, we can see that both κi andζi are negative constants. Therefore, if (24) holds,Δfi=0. So under the consensus algorithm and PI controller-based secondary frequency control, the frequency error will be eliminated. That is, when t⟶∞, Δfi⟶0. According to (22), it can be concluded that when the IC of each DG is equal, there is fMGref−fi=0, that is, the frequency recovery of DGi is realized. It is concluded that the proposed control scheme can achieve power optimization and secondary frequency control on the same time scale. Compared with the three-layer control structure, it can effectively shorten the operating time of the system and improve the operating efficiency of the microgrid.


## 3.1. Control Structure and Control Objectives

On the basis of P-f droop control, a consistent control strategy based on droop control is proposed to solve the problem of fully distributed data collection. Because there is no leader DG, dependence on the central controller under the centralized control structure is avoided. In this paper, a two-way communication network is adopted. Regarding each DG as an agent, the local controller of each agent exchanges IC information with the local controllers of its neighboring agents. Based on the transmission of IC information, the proposed consistency control strategy can simultaneously achieve frequency adjustment and optimal economic operation.The hierarchical control structure constructed in this article is different from the traditional three-layer structure. This article only needs to establish a two-layer structure. At the second layer, both power optimization and frequency recovery are realized, aiming to greatly shorten the optimization operation time, and significantly improve the stability and optimization operation efficiency of the microgrid. Taking the i-th DG as an example, the hierarchical control architecture with CPS characteristics is shown in Figure1.Figure 1
The hierarchical control architecture diagram of the i-th DG.The control objectives of this microgrid system can be summarized as follows:Goal 1: Frequency synchronization.(10)limt⟶∞fi−fj=0,∀i,j∈Ω.Goal 2: Frequency error-free.(11)limt⟶∞fi−fMGref=0,∀i∈Ω.Goal 3: Consistent incremental cost.(12)limt⟶∞λiPi−λjPj=0,∀i,j∈Ω.In addition, the system also needs to meet the power balance constraints and the upper and lower limits of DG generation power, which have been explained in the previous section and will not be explained here.


## 3.2. Primary Control Strategy

The primary control considers the use of traditional droop control to achieve frequency stability, which is given as follows:(13)fi=fMGref−miPi−Piref.For a microgrid composed of multiple DGs in parallel, the frequency of each DG is equal, that is,fi is equal. However, droop control is a differential control. Therefore, to make the frequency of each DG equal to the system frequency, a common method is to add frequency compensation to restorefi to fMGref.


## 3.3. Secondary Frequency Modulation and Power Optimization Control Strategy

The primary control only acts on the controllable DG unit of the physical layer, and the second layer control has been upgraded from the physical layer to the cyber layer, and requires sparse communication between DGs to achieve information exchange and coordinated control. Since the control scheme adopts a ring communication network to transmit the IC information of DGs, it can eliminate the requirement of Leader DG, reduce the information exchange between DGs, and improve efficiency. Since reactive power does not incur any costs, there is no need to discuss reactive power sharing schemes.For the goal of frequency error-free control, it is realized by adding a PI controller, and the compensation amount is calculated according to the following formula:(14)δf=kP,ifMGref−fi+kI,i∫fMGref−fidt.Aiming at the realization of the power optimization goal, without considering the DG capacity constraints, the control equation is designed as follows [21]:(15)Piref=∑j=1naijλj−λi−bi2ai,(16)fi=fMGref−miPi−Piref+kP,ifMGref−fi+kI,i∫fMGref−fidt.The IC information is selected as the consistency variable, and the local controller of DGi updates the reference powerPiref according to (15). In addition, the system frequency is stabilized based on (16). That is to say, the proposed method can update the output power reference value according to the neighboring IC information, and realize economic operation and frequency recovery, which is convenient to implement and simplifies the control loop.The process of equations (15) and (16) to achieve frequency recovery and power optimization is as follows.The matrix form of (15) and (16) is expressed as follows:(17)Pref=12a−1Αλ−λ−b,(18)f=fMGref−MP−Pref+KpfMGref−f+KIΔ,where Pref=P1ref,P2ref,…,PnrefTa=diaga1,a2,a3,⋯anλ=λ1,λ2,⋯,λnTb=b1,b2,…,bnTKp=diagkp,1,kp,2,…,kp,nKI=diagkI,1,kI,2,…,nkI,nf=f1,f2,…,fnT, fMGref=fMGref1n, P=P1,P2,…,PnT, Δ=∫fMGref−fdt.The design of the adjacency matrix in this paper is as follows:(19)A=01⋯01101⋯0010⋯0⋯⋯⋯⋯110⋯1⋯n×n.According to (17) and (18), (20) can be obtained as follows:(20)Lλ=2aM−1E+KPΔf+KIΔ,where Δf=fMGref−f.The Laplacian matrix of the communication graph has the following form:(21)L=2−1⋯0−1−12−1⋯00−12⋯0⋯⋯⋯⋯−1−10⋯−12n×n.According to (20), (22) can be obtained as follows:(22)−∑j=1naijλi−λj=κiΔfi+ζi∫Δfidt,where Δfi=fMGref−fi, κi=−2ai/mi1+kp,i, and ζi=−2aikI,i/mi.The left side of (22) denotes the consistency control, which can be defined as follows:(23)uit=−∑j=1naijλi−λj.Taking the IC as a consistency variable, the state of each variable will eventually be consistent under the control of the consistency algorithm, that is:λi=λj. Thus,(24)κiΔfi+ζi∫Δfidt=0.From the expressions ofκi andζi, we can see that both κi andζi are negative constants. Therefore, if (24) holds,Δfi=0. So under the consensus algorithm and PI controller-based secondary frequency control, the frequency error will be eliminated. That is, when t⟶∞, Δfi⟶0. According to (22), it can be concluded that when the IC of each DG is equal, there is fMGref−fi=0, that is, the frequency recovery of DGi is realized. It is concluded that the proposed control scheme can achieve power optimization and secondary frequency control on the same time scale. Compared with the three-layer control structure, it can effectively shorten the operating time of the system and improve the operating efficiency of the microgrid.


## 4. Control Strategies to against DOS Attacks

### 4.1. DoS Attack Modeling

The communication between DGs in MG is implemented based on the UDP protocol, which is a universal and easily affected protocol. In the process of communication, the data packets containing the IC information are transmitted through the channel, received by the data receiver of the DGs, written into the data buffer, and processed by the consistency controller in the DGs. Due to the openness of the communication network, the secondary control layer is easily attacked by attackers. The data path from the cyber layer DGi to DGj is shown in Figure2.Figure 2
Data path from DGi to DGj.The goal of DoS attack is to try to destroy the availability of data transmission and block the information transmission between DGs, thus making the secondary control strategy of microgrid invalid. Due to the attacker’s limited energy, DoS attacks are distributed in sequence in time. Define the attack start time on the communication link.i,j∈Ω asTkij, Tkij≥0.The duration of the attack is τkijτkij≥0k∈N+, and satisfied Tk+1ij>Tkij+τkij. Then the k-th DoS attack can be expressed as Ukij=Tkij,Tkij+τkij. Ut0,tij=∪Ukijt0,t represents the total DoS attack sequence set in the time interval t0,t.Assuming that data packets are transmitted through channels, routers provided by service providers, and other network equipment. Due to the openness and sharing of wireless media, sensor nodes are vulnerable to different network attacks. In this paper, it is assumed that the attacker launches DoS attacks on the router of the service provider, and the most direct impact of DoS attacks is the loss of data packets.Defineαi andαj as the packet loss rate of transmitted data after DGi and DGj are attacked respectively. The Equation is as follows:(25)uit=−∑j=1naij1−αiλi−1−αjλj.When a DG in the microgrid suffers DoS attacks, the impact of the attack will gradually propagate throughout the network, which will seriously affect the authenticity of the data. Since DG can only judge the existence of attacks byλi, λj and the tracking error. However, the tracking error will also converge to 0 in the presence of DoS attacks. Therefore, the DG itself can not directly use the above information to judge whether there is an attack or not, nor can it eliminate the influence of attacks.


### 4.2. DoS Attack Detection

Intrusion detection, as an important means to ensure network security, can monitor network activities in real-time, judge the state of equipment, find the attacked equipment in time, and then take corresponding countermeasures. Traditional intrusion detection methods are to identify behaviors that are significantly different from normal traffic as abnormal behaviors. This method does not require prior knowledge of abnormal network behaviors and can achieve better detection accuracy.Under the CPS architecture, it is known that the attack will cause the data packets sent by the router to be abnormal, so the change of the data packets can be used as the basis for detection.Define the detection function for DoS attacks on communication linki,j∈Ω asθijt, θijt∈0,1. When DoS attacks occur on the communication link i,j∈Ω, the detection function θijt can detect that the attack has occurred, and its value is set to 1 and kept, denoted asθijt:⟶1. When there are no DoS attacks, the value of θijt is set to 0 and kept, which is recorded asθijt:⟶0. All θijt are independent. The mathematical probability formula combined with the previous DoS attack model can be expressed as follows:(26)Probθijt=1=Eθijt=γijProbθijt=0=1−Eθijt=1−γij,where γij∈0,1 is a known constant and is related toαi andαj.


### 4.3. Event-Triggered Control

Taking into account the limited communication bandwidth between the agents in the microgrid, this paper uses event-triggered control to reduce the amount of communication between the agents. Due to the different degrees of DoS attacks, the defined packet loss rateα is a constant between0,1. When the packet loss rate is within the controllable range, an improved consistency formula based on event-triggered is proposed, and the influence of DoS attacks on the consistency control process is overcome by setting the gain coefficient kλi and the correction amountζ. However, when the packet loss rate is too high, that is, the extreme case of DoS attacks, the above methods can no longer meet the control requirements of the system. Therefore, it is considered to replace the real data with the data obtained by prediction compensation to complete the IC consistency control process.The improved consistency formula based on event-triggered is as follows:(27)uit=−kλi∑j=1naij1−αiλi−1−αjλj+ζ.This paper takes DG1 and DG2 as examples to give a brief proof process to illustrate the conditions that (27) must meet to complete the consistency control process. It is known that the incremental costs λ1 andλ2 satisfy the first-order equation.(28)λ˙1=u1λ˙2=u2,where u1t=−kλ1∑j=1na1j1−α1λ1−1−αjλj+ζu2t=−kλ2∑j=1na2j1−α1λ1−1−αjλj+ζ.Laplace transformation on the above formulas can be obtained:(29)λ1s=kλ1∑j=1na1j1−αjλjs+λ1t|t=0+ζ/ss+kλ1∑j=1na1j1−α1,(30)λ2s=kλ2∑j=1na2j1−αjλjs+λ2t|t=0+ζ/ss+kλ2∑j=1na2j1−α2.In the formulas,λ1s and λ2s are the state quantities of the IC after Laplace transformation, and λ1t|t=0 andλ2t|t=0 are the initial values of the IC of DG1 and DG2, respectively. Define the IC state deviation obtained by DG1 and DG2 as follows:(31)et=λ1t−λ2t,(32)limt⟶∞et=lims⟶0ses=lims⟶0sλ1s−λ2s=ζkλ2∑j=1na2j1−α2+kλ1∑j=1na1j1−α1kλ1∑j=1na1j1−α1⋅kλ2∑j=1na2j1−α2.At this time, whenkλi andζ meet the following condition, the system can meet the consistency requirements.(33)ζkλ2∑j=1na2j1−α2+kλ1∑j=1na1j1−α1kλ1∑j=1na1j1−α1⋅kλ2∑j=1na2j1−α2=0.Set the triggered functions toS1t, S2t andS3t, which are defined as follows according to the previous description:(34)S1t=i,j∈Ω:θijt=0S2t=i,j∈Ω:θijt=1andαi∪αj∈0,1S3t=i,j∈Ω:θijt=1andαi∩αj=1.When the triggered condition of (34) is met, DGi will send a request to the DGj to obtain its state information and update the control parameters. Among them, triggered condition S1t means that when the detection functionθijt=0 on the communication linki,j∈Ω, that is, when the link is not subjected to DoS attacks, the control process is directly completed by (23). S2t means that whenθijt=1 on the communication linki,j∈Ω, that is, when the link is under DoS attacks and the packet loss rate is within the controllable range, the control process is completed by (27). S3t means that whenθijt=1 on the communication linki,j∈Ω, that is, when the link is under DoS attacks and the packet loss rate is 1, the control process is completed by the predictive compensation control.


### 4.4. Predictive Compensation Control

The inability of agenti to receive the data of agent j will result in the inability to achieve the IC consistency, and thus fail to complete the restoration of the system frequency on the same time scale. In order to avoid the coupling problem between agents caused by directly predicting the data of agents, this paper uses the historical power data of agents at a moment in time, and calculates the IC through the predicted power, so as to obtain the corresponding control parameters.In order to better analyze the consistent dynamic characteristics, Equation (23) is discretized. Let the sampling period be Ts, t=t0+kTs, abbreviated as t=k. λk is sent every sampling period, and the corresponding discrete consistency algorithm can be written as follows:(35)λik+1=∑j=1nwijkλjk=λik+∑j≠iwijkλjk−λik,i=1,2,…,n.The corresponding matrix form is(36)λk+1=Wkλk.In order to ensure the consistency of the system and still converge to the average value,Wk is constructed according to the Metropolis method.According to whether the agent is attacked by DoS, set the control parameterλAi to indicate the latest update signal obtained by the agent i based on the event-triggered. When the triggered conditionS3t is met, λAi can be expressed as(37)λAi=θijkλci+1−θijkλi.Predictive compensation control is designed according to the following steps:(1)
EMD is used to preprocess the historical data, and multiple intrinsic mode functions(IMFs) are obtained from the historical data. The IMF component must meet the following two conditions:(i)
During the entire period, the number of extreme points and zero crossing points are equal, or the difference does not exceed 1(ii)
At any moment, the average value of the upper envelope and the lower envelope is zero(2)
For this series of IMFs, a sliding window is used to intercept historical time series to obtain data samples. Intercept the data sample of lengthD as an input sample, then the data at the next moment is the expected value output by the ELM model. [12].EMD is carried out in accordance with the flow chart given in Figure3. The structure of the entire ELM network is shown in Figure 4.Suppose that the input layer of the network hasn neurons, the output layer has m neurons, and the hidden layer has L neurons. The activation function is G⋅. Input sample X=IMF1,IMF2,⋯,IMFnT, output sample Y=pELM1,pELM2,⋯,pELMmT. The output function of the ELM model can be expressed as(38)fLX=∑j=1LβjGwj⋅IMFi+hj,i=1,2,⋯,n.Where:wj=wj1,wj2,⋯wjnT, βj=βj1,βj2,⋯βjmT are the input and output connection weight of the j-th hidden layer neuron.(3)
In order to make the model with the smallest prediction error have a larger weight, the outputs ofm ELMs are weighted as follows. The weighted result is(39)PELM=∑i=1mηiPELMi.Where:ηi=∑i=1mei−ei/m−1∑i=1mei. ei=Pi−PELMi.Then when the agent is attacked, the IC obtained after the predictive compensation control is as follows:(40)λci=2aiPELM+bi.Figure 3
Flow chart of EMD algorithm.Figure 4
Topology diagram of ELM structure.


## 4.1. DoS Attack Modeling

The communication between DGs in MG is implemented based on the UDP protocol, which is a universal and easily affected protocol. In the process of communication, the data packets containing the IC information are transmitted through the channel, received by the data receiver of the DGs, written into the data buffer, and processed by the consistency controller in the DGs. Due to the openness of the communication network, the secondary control layer is easily attacked by attackers. The data path from the cyber layer DGi to DGj is shown in Figure2.Figure 2
Data path from DGi to DGj.The goal of DoS attack is to try to destroy the availability of data transmission and block the information transmission between DGs, thus making the secondary control strategy of microgrid invalid. Due to the attacker’s limited energy, DoS attacks are distributed in sequence in time. Define the attack start time on the communication link.i,j∈Ω asTkij, Tkij≥0.The duration of the attack is τkijτkij≥0k∈N+, and satisfied Tk+1ij>Tkij+τkij. Then the k-th DoS attack can be expressed as Ukij=Tkij,Tkij+τkij. Ut0,tij=∪Ukijt0,t represents the total DoS attack sequence set in the time interval t0,t.Assuming that data packets are transmitted through channels, routers provided by service providers, and other network equipment. Due to the openness and sharing of wireless media, sensor nodes are vulnerable to different network attacks. In this paper, it is assumed that the attacker launches DoS attacks on the router of the service provider, and the most direct impact of DoS attacks is the loss of data packets.Defineαi andαj as the packet loss rate of transmitted data after DGi and DGj are attacked respectively. The Equation is as follows:(25)uit=−∑j=1naij1−αiλi−1−αjλj.When a DG in the microgrid suffers DoS attacks, the impact of the attack will gradually propagate throughout the network, which will seriously affect the authenticity of the data. Since DG can only judge the existence of attacks byλi, λj and the tracking error. However, the tracking error will also converge to 0 in the presence of DoS attacks. Therefore, the DG itself can not directly use the above information to judge whether there is an attack or not, nor can it eliminate the influence of attacks.


## 4.2. DoS Attack Detection

Intrusion detection, as an important means to ensure network security, can monitor network activities in real-time, judge the state of equipment, find the attacked equipment in time, and then take corresponding countermeasures. Traditional intrusion detection methods are to identify behaviors that are significantly different from normal traffic as abnormal behaviors. This method does not require prior knowledge of abnormal network behaviors and can achieve better detection accuracy.Under the CPS architecture, it is known that the attack will cause the data packets sent by the router to be abnormal, so the change of the data packets can be used as the basis for detection.Define the detection function for DoS attacks on communication linki,j∈Ω asθijt, θijt∈0,1. When DoS attacks occur on the communication link i,j∈Ω, the detection function θijt can detect that the attack has occurred, and its value is set to 1 and kept, denoted asθijt:⟶1. When there are no DoS attacks, the value of θijt is set to 0 and kept, which is recorded asθijt:⟶0. All θijt are independent. The mathematical probability formula combined with the previous DoS attack model can be expressed as follows:(26)Probθijt=1=Eθijt=γijProbθijt=0=1−Eθijt=1−γij,where γij∈0,1 is a known constant and is related toαi andαj.


## 4.3. Event-Triggered Control

Taking into account the limited communication bandwidth between the agents in the microgrid, this paper uses event-triggered control to reduce the amount of communication between the agents. Due to the different degrees of DoS attacks, the defined packet loss rateα is a constant between0,1. When the packet loss rate is within the controllable range, an improved consistency formula based on event-triggered is proposed, and the influence of DoS attacks on the consistency control process is overcome by setting the gain coefficient kλi and the correction amountζ. However, when the packet loss rate is too high, that is, the extreme case of DoS attacks, the above methods can no longer meet the control requirements of the system. Therefore, it is considered to replace the real data with the data obtained by prediction compensation to complete the IC consistency control process.The improved consistency formula based on event-triggered is as follows:(27)uit=−kλi∑j=1naij1−αiλi−1−αjλj+ζ.This paper takes DG1 and DG2 as examples to give a brief proof process to illustrate the conditions that (27) must meet to complete the consistency control process. It is known that the incremental costs λ1 andλ2 satisfy the first-order equation.(28)λ˙1=u1λ˙2=u2,where u1t=−kλ1∑j=1na1j1−α1λ1−1−αjλj+ζu2t=−kλ2∑j=1na2j1−α1λ1−1−αjλj+ζ.Laplace transformation on the above formulas can be obtained:(29)λ1s=kλ1∑j=1na1j1−αjλjs+λ1t|t=0+ζ/ss+kλ1∑j=1na1j1−α1,(30)λ2s=kλ2∑j=1na2j1−αjλjs+λ2t|t=0+ζ/ss+kλ2∑j=1na2j1−α2.In the formulas,λ1s and λ2s are the state quantities of the IC after Laplace transformation, and λ1t|t=0 andλ2t|t=0 are the initial values of the IC of DG1 and DG2, respectively. Define the IC state deviation obtained by DG1 and DG2 as follows:(31)et=λ1t−λ2t,(32)limt⟶∞et=lims⟶0ses=lims⟶0sλ1s−λ2s=ζkλ2∑j=1na2j1−α2+kλ1∑j=1na1j1−α1kλ1∑j=1na1j1−α1⋅kλ2∑j=1na2j1−α2.At this time, whenkλi andζ meet the following condition, the system can meet the consistency requirements.(33)ζkλ2∑j=1na2j1−α2+kλ1∑j=1na1j1−α1kλ1∑j=1na1j1−α1⋅kλ2∑j=1na2j1−α2=0.Set the triggered functions toS1t, S2t andS3t, which are defined as follows according to the previous description:(34)S1t=i,j∈Ω:θijt=0S2t=i,j∈Ω:θijt=1andαi∪αj∈0,1S3t=i,j∈Ω:θijt=1andαi∩αj=1.When the triggered condition of (34) is met, DGi will send a request to the DGj to obtain its state information and update the control parameters. Among them, triggered condition S1t means that when the detection functionθijt=0 on the communication linki,j∈Ω, that is, when the link is not subjected to DoS attacks, the control process is directly completed by (23). S2t means that whenθijt=1 on the communication linki,j∈Ω, that is, when the link is under DoS attacks and the packet loss rate is within the controllable range, the control process is completed by (27). S3t means that whenθijt=1 on the communication linki,j∈Ω, that is, when the link is under DoS attacks and the packet loss rate is 1, the control process is completed by the predictive compensation control.


## 4.4. Predictive Compensation Control

The inability of agenti to receive the data of agent j will result in the inability to achieve the IC consistency, and thus fail to complete the restoration of the system frequency on the same time scale. In order to avoid the coupling problem between agents caused by directly predicting the data of agents, this paper uses the historical power data of agents at a moment in time, and calculates the IC through the predicted power, so as to obtain the corresponding control parameters.In order to better analyze the consistent dynamic characteristics, Equation (23) is discretized. Let the sampling period be Ts, t=t0+kTs, abbreviated as t=k. λk is sent every sampling period, and the corresponding discrete consistency algorithm can be written as follows:(35)λik+1=∑j=1nwijkλjk=λik+∑j≠iwijkλjk−λik,i=1,2,…,n.The corresponding matrix form is(36)λk+1=Wkλk.In order to ensure the consistency of the system and still converge to the average value,Wk is constructed according to the Metropolis method.According to whether the agent is attacked by DoS, set the control parameterλAi to indicate the latest update signal obtained by the agent i based on the event-triggered. When the triggered conditionS3t is met, λAi can be expressed as(37)λAi=θijkλci+1−θijkλi.Predictive compensation control is designed according to the following steps:(1)
EMD is used to preprocess the historical data, and multiple intrinsic mode functions(IMFs) are obtained from the historical data. The IMF component must meet the following two conditions:(i)
During the entire period, the number of extreme points and zero crossing points are equal, or the difference does not exceed 1(ii)
At any moment, the average value of the upper envelope and the lower envelope is zero(2)
For this series of IMFs, a sliding window is used to intercept historical time series to obtain data samples. Intercept the data sample of lengthD as an input sample, then the data at the next moment is the expected value output by the ELM model. [12].EMD is carried out in accordance with the flow chart given in Figure3. The structure of the entire ELM network is shown in Figure 4.Suppose that the input layer of the network hasn neurons, the output layer has m neurons, and the hidden layer has L neurons. The activation function is G⋅. Input sample X=IMF1,IMF2,⋯,IMFnT, output sample Y=pELM1,pELM2,⋯,pELMmT. The output function of the ELM model can be expressed as(38)fLX=∑j=1LβjGwj⋅IMFi+hj,i=1,2,⋯,n.Where:wj=wj1,wj2,⋯wjnT, βj=βj1,βj2,⋯βjmT are the input and output connection weight of the j-th hidden layer neuron.(3)
In order to make the model with the smallest prediction error have a larger weight, the outputs ofm ELMs are weighted as follows. The weighted result is(39)PELM=∑i=1mηiPELMi.Where:ηi=∑i=1mei−ei/m−1∑i=1mei. ei=Pi−PELMi.Then when the agent is attacked, the IC obtained after the predictive compensation control is as follows:(40)λci=2aiPELM+bi.Figure 3
Flow chart of EMD algorithm.Figure 4
Topology diagram of ELM structure.


## 5. Calculation Examples and Simulation

### 5.1. Simulation Model

In this section, the simulation topology is a four-node microgrid system, as shown in Figure5.Figure 5
Islanded microgrid structure.The MATLAB/SIMULINK to verify the two-layer control strategy proposed above. The microgrid system consists of 4 DGs, the impedance of the power supply is taken asZi=0.0679+j4.11×10−4Ω. The line impedances meet Zl1=Zl3 andZl2=Zl4. Taking as 0.175+j4.04×10−4Ω and0.12+j4.04×10−4Ω. The simulation parameters and cost coefficients of each DG are shown in Table 1.Table 1
Simulation parameters and cost coefficients of each DG.
DGiPirefmiLoad1∼Load4aibiciDG180×1031×10−560kw+10jkVar1.594×10−32.0252×10−20.8466DG270×1031×10−590kw+10jkVar1.195×10−35.6606×10−20.5146DG360×1031×10−580kw+0jkVar1.743×10−34.1998×10−21.2948DG450×1031×10−570kw+10jkVar1.361×10−36.6732×10−20.6972


### 5.2. Performance Test and Comparison under Two-Layer Control Structure

#### 5.2.1. Comparison with Traditional Three-Layer Control

In order to verify the advanced nature of the proposed control strategy, the two-layer control method in this study is compared with the distributed three-layer control method designed in Reference [27]. Set the simulation environment as: 0∼1s, only droop control is used, and at t=1s, the upper control is activated. The simulation results under the two control strategies are shown in Figure 6.Figure 6
Comparison of control effects of two hierarchical structures.
(a)(b)(c)(d)(e)(f)Figures6(a)–6(c) are the simulation results of the traditional three-layer control method, and Figures 6(d)–6(f) are the simulation results of the two-layer control method proposed in this paper. It can be seen that after the upper-layer control is activated, both methods can achieve the goals of frequency regulation and power optimization, but compared with the three-layer control method corresponding to Figures 6(a)–6(c), the method proposed in this paper has a faster power optimization speed. The traditional three-layer control needs 0.5 s to achieve incremental factor synchronization, while the control proposed in this paper only needs 0.2 s, which shows that the performance of the two-layer control strategy is better than the traditional three-layer control.


#### 5.2.2. System Performance during Load Fluctuations

This part tests the frequency recovery and power optimization effects when the load fluctuates. The system is connected to the control strategy proposed in this study for power optimization and frequency recovery att=1s, and disconnected at t=6s.Set the simulation environment as: (1) At t=2s, Load 1 increases to 70 kw. (2) At t=3s, Load 2 increases to 100 kw. (3) At t=4s, Load 3 is reduced to 70 kw. (4) At t=5s, Load 4 is reduced to 60 kw. The simulation results are shown in Figure 7.Figure 7
Frequency recovery and power optimization results when load fluctuates.
(a)(b)(c)Figures7(a)–7(c) show the changes in the output active power, incremental cost, and frequency of these four DGs, respectively. As can be seen from Figure 7(b), the initial values of ICs are 0.3075$/kWh0.2484$/kWh0.2865$/kWh, 0.2306$/kWh. After starting the control strategy at t=1s, the IC of each DG tends to be consistent and finally stabilizes at 0.2651$/kWh. After the load demand changes, the IC can still be consistent. It can be concluded that no matter how the load is changed, the IC of each DG can be driven to the same level under the control strategy designed in this study, so the control objectives are well met. As can be seen from Figure 7(c), the frequency of the microgrid can be stabilized at the nominal value of 50 Hz, and the frequency changes little. Therefore, the proposed control scheme can effectively realize the economic operation and frequency adjustment of the islanded microgrid without considering the DG capacity constraints.


#### 5.2.3. System Plug and Play Performance

The distributed control method requires the system to be able to meet the change of topology, so in order to verify the plug-and-play performance of the method in this paper, the simulation process is as follows: The islanded microgrid runs under the condition of total constant load demand of 280 kW, the specific load requirements are shown in Table2. The system accesses the second-layer control strategy for power optimization and frequency recovery at t=1s, and disconnects at t=6s. Set the simulation environment as: (1) At t=2s, DG1 is cut off from system. (2) When t=4s, DG1 is put into the system, and the connection with the system is restored. Figure 8 shows the change in communication topology. The other control parameters and cost coefficients of DG are the same as above and remain unchanged. The simulation results are shown in Figure 9.Table 2
Load demand of each DG.
LoadiLoad1Load2Load3Load4Value,kW01009090Figure 8
Schematic diagram of communication topology changes.Figure 9
System plug-and-play simulation results.
(a)(b)(c)As can be seen from Figures9(a)–9(c), the system can operate stably during the DG input and removal process. Figure 9(a) shows that due to DG1 exiting operation at t=2s, the output power of DG1 is reduced to zero, and DG2, DG3, and DG4 share the total load of the system. At t=4s, DG1 reconnects to the microgrid, and its output power increases from 0 to 7.237 kW. Figure 9(b) shows that in the whole process, although the DGs have changed, the ICs of DGs participating in the power supply are always consistent, so the control requirements can be well met. In addition, Figure 9(c) shows that when the DGs change, the frequency fluctuation can be restored to the nominal value in a short time. Therefore, the proposed control method can well meet the plug-and-play requirement of the microgrid system.


#### 5.2.4. DoS Attack Impact Analysis

As mentioned earlier, the impact of DoS attacks is modeled as data loss that occurs on the communication linki,j∈Ω, the size of the packet loss rate directly affects the speed and the effect of the consistency convergence process. In order to analyze the impact of different packet loss rates on system control objectives, the simulation process is set as follows: The studied islanded microgrid runs under the simulation parameters of Table 1, and accesses the second-layer control strategy at t=4s, and disconnects at t=6s. In the communication system, the data transmitted by DG1 to other DGs during the period t1=2s to t2=4s is under attack, and the packet loss rate isα1. The results of the system frequency and the IC of each DG in the period t1∼t2 under different packet loss rates are shown in Figure 10.Figure 10
Comparison of the impact of DoS attacks.
(a)(b)(c)(d)As can be seen from Figures10(a) and 10(b), when the packet loss rate is small, the impact of the attack on DG1 is mainly causes the IC curve of DG1 to produce a large overshoot during this period, which deviates from the consistent value reached by the system except for DG1. The system frequency fluctuates during the attack period and deviates from the nominal frequency of 50 Hz. As can be seen from Figures 10(c) and 10(d), when the packet loss rate is large, the consistency control of the IC in the period t1∼t2 fails, and the change of DG1 is the largest. The system frequency has a great overshoot at the moment of the attack and greatly deviates from the nominal frequency. Therefore it can be concluded that the main impact is the consistency control process of the IC, and the secondary control method is still effective in the rest of the time.


### 5.3. Verify the Effect of Improving Consistency Strategy

In order to verify the effectiveness of the improved consistency strategy based on event-triggered in the case of weaker DoS attacks for frequency restoration and power optimization of the microgrid, use the same simulation process. Select the time periodt1∼t2 during which DoS attacks occur, and the simulation time is 2s. Assuming that at t1=1s, the system detects DoS attacks, and then initiates the improved consistency strategy based on event-triggered. The results of changes in the IC and frequency are shown in Figure 11.Figure 11
Comparison of control effects of improved consistency strategy.
(a)(b)(c)(d)As can be seen from Figures11(a) and 11(b), starting the improved consistency strategy can restore the destroyed IC consistency. The recovery time is about 0.05s. The system frequency can achieve stability after fluctuations. When the packet loss rate is large, as can be seen from Figures 11(c) and 11(d), the improved consistency strategy is still effective, but the consistency recovery time of the IC is prolonged, about 0.35s. The system frequency has a large overshoot during the recovery process, but it can still be stabilized at 50 Hz. It can be concluded that in the case of weaker DoS attacks, the improved consistency strategy based on event-triggered can achieve our control goals, which proves the effectiveness of the proposed strategy.


### 5.4. Verify the Effect of Predictive Compensation Control

As mentioned above, when an extreme situation occurs in DoS attacks, consider using the data obtained by predictive compensation control instead of the real data to complete the IC consistency control process. Select time periodt1∼t2 when the DoS attack occurs. The changes in IC and system frequency are shown in Figure 12. When a DG suffers DoS attacks to completely drop its packets, the attacks will gradually spread throughout the network, which will seriously affect the fidelity of the information. After t1=1s, because the event-triggered mechanism calculates the impact of packet loss on the secondary control, the predicted data obtained from the output of the predictive compensation is used to replace the real data to complete the subsequent consistency control process.Figure 12
Predictive compensation strategy control effect diagram.
(a)(b)As can be seen from Figures12(a) and 12(b), the IC and frequency of each DG can be restored to be consistent at about 0.3 s. According to the above analysis, for extreme DoS attacks, the secondary control strategy based on event-triggered can well use the predictive compensation data to suppress the overshoot and complete the IC consistency control process, while stabilizing the system frequency at the nominal value.


## 5.1. Simulation Model

In this section, the simulation topology is a four-node microgrid system, as shown in Figure5.Figure 5
Islanded microgrid structure.The MATLAB/SIMULINK to verify the two-layer control strategy proposed above. The microgrid system consists of 4 DGs, the impedance of the power supply is taken asZi=0.0679+j4.11×10−4Ω. The line impedances meet Zl1=Zl3 andZl2=Zl4. Taking as 0.175+j4.04×10−4Ω and0.12+j4.04×10−4Ω. The simulation parameters and cost coefficients of each DG are shown in Table 1.Table 1
Simulation parameters and cost coefficients of each DG.
DGiPirefmiLoad1∼Load4aibiciDG180×1031×10−560kw+10jkVar1.594×10−32.0252×10−20.8466DG270×1031×10−590kw+10jkVar1.195×10−35.6606×10−20.5146DG360×1031×10−580kw+0jkVar1.743×10−34.1998×10−21.2948DG450×1031×10−570kw+10jkVar1.361×10−36.6732×10−20.6972


## 5.2. Performance Test and Comparison under Two-Layer Control Structure

### 5.2.1. Comparison with Traditional Three-Layer Control

In order to verify the advanced nature of the proposed control strategy, the two-layer control method in this study is compared with the distributed three-layer control method designed in Reference [27]. Set the simulation environment as: 0∼1s, only droop control is used, and at t=1s, the upper control is activated. The simulation results under the two control strategies are shown in Figure 6.Figure 6
Comparison of control effects of two hierarchical structures.
(a)(b)(c)(d)(e)(f)Figures6(a)–6(c) are the simulation results of the traditional three-layer control method, and Figures 6(d)–6(f) are the simulation results of the two-layer control method proposed in this paper. It can be seen that after the upper-layer control is activated, both methods can achieve the goals of frequency regulation and power optimization, but compared with the three-layer control method corresponding to Figures 6(a)–6(c), the method proposed in this paper has a faster power optimization speed. The traditional three-layer control needs 0.5 s to achieve incremental factor synchronization, while the control proposed in this paper only needs 0.2 s, which shows that the performance of the two-layer control strategy is better than the traditional three-layer control.


### 5.2.2. System Performance during Load Fluctuations

This part tests the frequency recovery and power optimization effects when the load fluctuates. The system is connected to the control strategy proposed in this study for power optimization and frequency recovery att=1s, and disconnected at t=6s.Set the simulation environment as: (1) At t=2s, Load 1 increases to 70 kw. (2) At t=3s, Load 2 increases to 100 kw. (3) At t=4s, Load 3 is reduced to 70 kw. (4) At t=5s, Load 4 is reduced to 60 kw. The simulation results are shown in Figure 7.Figure 7
Frequency recovery and power optimization results when load fluctuates.
(a)(b)(c)Figures7(a)–7(c) show the changes in the output active power, incremental cost, and frequency of these four DGs, respectively. As can be seen from Figure 7(b), the initial values of ICs are 0.3075$/kWh0.2484$/kWh0.2865$/kWh, 0.2306$/kWh. After starting the control strategy at t=1s, the IC of each DG tends to be consistent and finally stabilizes at 0.2651$/kWh. After the load demand changes, the IC can still be consistent. It can be concluded that no matter how the load is changed, the IC of each DG can be driven to the same level under the control strategy designed in this study, so the control objectives are well met. As can be seen from Figure 7(c), the frequency of the microgrid can be stabilized at the nominal value of 50 Hz, and the frequency changes little. Therefore, the proposed control scheme can effectively realize the economic operation and frequency adjustment of the islanded microgrid without considering the DG capacity constraints.


### 5.2.3. System Plug and Play Performance

The distributed control method requires the system to be able to meet the change of topology, so in order to verify the plug-and-play performance of the method in this paper, the simulation process is as follows: The islanded microgrid runs under the condition of total constant load demand of 280 kW, the specific load requirements are shown in Table2. The system accesses the second-layer control strategy for power optimization and frequency recovery at t=1s, and disconnects at t=6s. Set the simulation environment as: (1) At t=2s, DG1 is cut off from system. (2) When t=4s, DG1 is put into the system, and the connection with the system is restored. Figure 8 shows the change in communication topology. The other control parameters and cost coefficients of DG are the same as above and remain unchanged. The simulation results are shown in Figure 9.Table 2
Load demand of each DG.
LoadiLoad1Load2Load3Load4Value,kW01009090Figure 8
Schematic diagram of communication topology changes.Figure 9
System plug-and-play simulation results.
(a)(b)(c)As can be seen from Figures9(a)–9(c), the system can operate stably during the DG input and removal process. Figure 9(a) shows that due to DG1 exiting operation at t=2s, the output power of DG1 is reduced to zero, and DG2, DG3, and DG4 share the total load of the system. At t=4s, DG1 reconnects to the microgrid, and its output power increases from 0 to 7.237 kW. Figure 9(b) shows that in the whole process, although the DGs have changed, the ICs of DGs participating in the power supply are always consistent, so the control requirements can be well met. In addition, Figure 9(c) shows that when the DGs change, the frequency fluctuation can be restored to the nominal value in a short time. Therefore, the proposed control method can well meet the plug-and-play requirement of the microgrid system.


### 5.2.4. DoS Attack Impact Analysis

As mentioned earlier, the impact of DoS attacks is modeled as data loss that occurs on the communication linki,j∈Ω, the size of the packet loss rate directly affects the speed and the effect of the consistency convergence process. In order to analyze the impact of different packet loss rates on system control objectives, the simulation process is set as follows: The studied islanded microgrid runs under the simulation parameters of Table 1, and accesses the second-layer control strategy at t=4s, and disconnects at t=6s. In the communication system, the data transmitted by DG1 to other DGs during the period t1=2s to t2=4s is under attack, and the packet loss rate isα1. The results of the system frequency and the IC of each DG in the period t1∼t2 under different packet loss rates are shown in Figure 10.Figure 10
Comparison of the impact of DoS attacks.
(a)(b)(c)(d)As can be seen from Figures10(a) and 10(b), when the packet loss rate is small, the impact of the attack on DG1 is mainly causes the IC curve of DG1 to produce a large overshoot during this period, which deviates from the consistent value reached by the system except for DG1. The system frequency fluctuates during the attack period and deviates from the nominal frequency of 50 Hz. As can be seen from Figures 10(c) and 10(d), when the packet loss rate is large, the consistency control of the IC in the period t1∼t2 fails, and the change of DG1 is the largest. The system frequency has a great overshoot at the moment of the attack and greatly deviates from the nominal frequency. Therefore it can be concluded that the main impact is the consistency control process of the IC, and the secondary control method is still effective in the rest of the time.


## 5.2.1. Comparison with Traditional Three-Layer Control

In order to verify the advanced nature of the proposed control strategy, the two-layer control method in this study is compared with the distributed three-layer control method designed in Reference [27]. Set the simulation environment as: 0∼1s, only droop control is used, and at t=1s, the upper control is activated. The simulation results under the two control strategies are shown in Figure 6.Figure 6
Comparison of control effects of two hierarchical structures.
(a)(b)(c)(d)(e)(f)Figures6(a)–6(c) are the simulation results of the traditional three-layer control method, and Figures 6(d)–6(f) are the simulation results of the two-layer control method proposed in this paper. It can be seen that after the upper-layer control is activated, both methods can achieve the goals of frequency regulation and power optimization, but compared with the three-layer control method corresponding to Figures 6(a)–6(c), the method proposed in this paper has a faster power optimization speed. The traditional three-layer control needs 0.5 s to achieve incremental factor synchronization, while the control proposed in this paper only needs 0.2 s, which shows that the performance of the two-layer control strategy is better than the traditional three-layer control.


## 5.2.2. System Performance during Load Fluctuations

This part tests the frequency recovery and power optimization effects when the load fluctuates. The system is connected to the control strategy proposed in this study for power optimization and frequency recovery att=1s, and disconnected at t=6s.Set the simulation environment as: (1) At t=2s, Load 1 increases to 70 kw. (2) At t=3s, Load 2 increases to 100 kw. (3) At t=4s, Load 3 is reduced to 70 kw. (4) At t=5s, Load 4 is reduced to 60 kw. The simulation results are shown in Figure 7.Figure 7
Frequency recovery and power optimization results when load fluctuates.
(a)(b)(c)Figures7(a)–7(c) show the changes in the output active power, incremental cost, and frequency of these four DGs, respectively. As can be seen from Figure 7(b), the initial values of ICs are 0.3075$/kWh0.2484$/kWh0.2865$/kWh, 0.2306$/kWh. After starting the control strategy at t=1s, the IC of each DG tends to be consistent and finally stabilizes at 0.2651$/kWh. After the load demand changes, the IC can still be consistent. It can be concluded that no matter how the load is changed, the IC of each DG can be driven to the same level under the control strategy designed in this study, so the control objectives are well met. As can be seen from Figure 7(c), the frequency of the microgrid can be stabilized at the nominal value of 50 Hz, and the frequency changes little. Therefore, the proposed control scheme can effectively realize the economic operation and frequency adjustment of the islanded microgrid without considering the DG capacity constraints.


## 5.2.3. System Plug and Play Performance

The distributed control method requires the system to be able to meet the change of topology, so in order to verify the plug-and-play performance of the method in this paper, the simulation process is as follows: The islanded microgrid runs under the condition of total constant load demand of 280 kW, the specific load requirements are shown in Table2. The system accesses the second-layer control strategy for power optimization and frequency recovery at t=1s, and disconnects at t=6s. Set the simulation environment as: (1) At t=2s, DG1 is cut off from system. (2) When t=4s, DG1 is put into the system, and the connection with the system is restored. Figure 8 shows the change in communication topology. The other control parameters and cost coefficients of DG are the same as above and remain unchanged. The simulation results are shown in Figure 9.Table 2
Load demand of each DG.
LoadiLoad1Load2Load3Load4Value,kW01009090Figure 8
Schematic diagram of communication topology changes.Figure 9
System plug-and-play simulation results.
(a)(b)(c)As can be seen from Figures9(a)–9(c), the system can operate stably during the DG input and removal process. Figure 9(a) shows that due to DG1 exiting operation at t=2s, the output power of DG1 is reduced to zero, and DG2, DG3, and DG4 share the total load of the system. At t=4s, DG1 reconnects to the microgrid, and its output power increases from 0 to 7.237 kW. Figure 9(b) shows that in the whole process, although the DGs have changed, the ICs of DGs participating in the power supply are always consistent, so the control requirements can be well met. In addition, Figure 9(c) shows that when the DGs change, the frequency fluctuation can be restored to the nominal value in a short time. Therefore, the proposed control method can well meet the plug-and-play requirement of the microgrid system.


## 5.2.4. DoS Attack Impact Analysis

As mentioned earlier, the impact of DoS attacks is modeled as data loss that occurs on the communication linki,j∈Ω, the size of the packet loss rate directly affects the speed and the effect of the consistency convergence process. In order to analyze the impact of different packet loss rates on system control objectives, the simulation process is set as follows: The studied islanded microgrid runs under the simulation parameters of Table 1, and accesses the second-layer control strategy at t=4s, and disconnects at t=6s. In the communication system, the data transmitted by DG1 to other DGs during the period t1=2s to t2=4s is under attack, and the packet loss rate isα1. The results of the system frequency and the IC of each DG in the period t1∼t2 under different packet loss rates are shown in Figure 10.Figure 10
Comparison of the impact of DoS attacks.
(a)(b)(c)(d)As can be seen from Figures10(a) and 10(b), when the packet loss rate is small, the impact of the attack on DG1 is mainly causes the IC curve of DG1 to produce a large overshoot during this period, which deviates from the consistent value reached by the system except for DG1. The system frequency fluctuates during the attack period and deviates from the nominal frequency of 50 Hz. As can be seen from Figures 10(c) and 10(d), when the packet loss rate is large, the consistency control of the IC in the period t1∼t2 fails, and the change of DG1 is the largest. The system frequency has a great overshoot at the moment of the attack and greatly deviates from the nominal frequency. Therefore it can be concluded that the main impact is the consistency control process of the IC, and the secondary control method is still effective in the rest of the time.


## 5.3. Verify the Effect of Improving Consistency Strategy

In order to verify the effectiveness of the improved consistency strategy based on event-triggered in the case of weaker DoS attacks for frequency restoration and power optimization of the microgrid, use the same simulation process. Select the time periodt1∼t2 during which DoS attacks occur, and the simulation time is 2s. Assuming that at t1=1s, the system detects DoS attacks, and then initiates the improved consistency strategy based on event-triggered. The results of changes in the IC and frequency are shown in Figure 11.Figure 11
Comparison of control effects of improved consistency strategy.
(a)(b)(c)(d)As can be seen from Figures11(a) and 11(b), starting the improved consistency strategy can restore the destroyed IC consistency. The recovery time is about 0.05s. The system frequency can achieve stability after fluctuations. When the packet loss rate is large, as can be seen from Figures 11(c) and 11(d), the improved consistency strategy is still effective, but the consistency recovery time of the IC is prolonged, about 0.35s. The system frequency has a large overshoot during the recovery process, but it can still be stabilized at 50 Hz. It can be concluded that in the case of weaker DoS attacks, the improved consistency strategy based on event-triggered can achieve our control goals, which proves the effectiveness of the proposed strategy.


## 5.4. Verify the Effect of Predictive Compensation Control

As mentioned above, when an extreme situation occurs in DoS attacks, consider using the data obtained by predictive compensation control instead of the real data to complete the IC consistency control process. Select time periodt1∼t2 when the DoS attack occurs. The changes in IC and system frequency are shown in Figure 12. When a DG suffers DoS attacks to completely drop its packets, the attacks will gradually spread throughout the network, which will seriously affect the fidelity of the information. After t1=1s, because the event-triggered mechanism calculates the impact of packet loss on the secondary control, the predicted data obtained from the output of the predictive compensation is used to replace the real data to complete the subsequent consistency control process.Figure 12
Predictive compensation strategy control effect diagram.
(a)(b)As can be seen from Figures12(a) and 12(b), the IC and frequency of each DG can be restored to be consistent at about 0.3 s. According to the above analysis, for extreme DoS attacks, the secondary control strategy based on event-triggered can well use the predictive compensation data to suppress the overshoot and complete the IC consistency control process, while stabilizing the system frequency at the nominal value.


## 6. Conclusion

This paper proposes a distributed two-layer control structure for the islanded microgrid system with CPS characteristics. The control structure can realize the distributed frequency adjustment and power optimization of the microgrid at the same time, effectively shortening the operating time of the system, and significantly improving the power optimization distribution capability of the microgrid. Aiming at the possible network attacks at the cyber layer, in order to reduce the impact of different degrees of DoS attacks on the system, this paper designs an improved consensus algorithm based on event-triggered and predictive compensation control that combines EMD and ELM. Finally, the 4-node MG system is simulated and analyzed, and the experimental results show that this method can effectively eliminate the influence of DoS attacks on consistency control, keep the system frequency at 50 Hz, and keep the IC consistency of all DGs. The results show that this method can meet the control requirements of frequency synchronization, frequency error-free, and optimal operation cost.



---

*Source: 1348667-2022-09-08.xml*