An Adaptive Hierarchical Control Method for Microgrid Considering Generation Cost

Many power distribution methods of microgrid (MG) are all limited by fixed structure of MG and mathematical model, which will be out of effect once the structure changes. In order to solve the above problems, this paper proposed an adaptive hierarchical control method considering generation cost. Firstly, the distributed generators (DGs) of MG are considered as multi-agent system, and the secondary controller based on finite-time theory is constructed. Secondly, the improved gray wolf optimization (IGWO) algorithm is used as the tertiary controller to dynamically optimize the rated power of DG, and the objective function and constraints are established. Thirdly, the adaptive virtual impedance is introduced to realize accurate power sharing and the closed-loop control is formed by combining the current loop and voltage loop controllers. Finally, by dynamically optimizing the rated power, the on-line real-time optimal power distribution of MG is achieved, and the stability of the system is proved by the theories of multi-agent consistency and finite-time stability. The control method proposed in this paper accelerates the convergence speed of MG, and the calculation results have high accuracy. At the same time, the flexibility and reliability of MG are improved. The simulation model is established in Matlab/Simulink environment, and the simulation results show that the method is effective.


I. INTRODUCTION
Microgrid (MG) is a distributed system, which is composed of several distributed generators (DGs), energy storage equipment and loads [1], [2]. It usually has two working modes, islanded mode and grid-connected mode [3]. The distributed generators are usually renewable energy [4], which includes wind, solar and nuclear energy etc. [4]. However, the utilization of new energy such as solar energy and wind energy is uncertain. Once used improperly, it may lead to instability of power grid and even collapse of power grid system. Therefore, with the popularization and application of MG, the control technology of MG is particularly important. An effective and reasonable control strategy is the basis of stable operation of MG. The generation cost for each renewable energy source is different. When the power generated by DG is different, the operation cost of MG is also different. Therefore, it is necessary for us to distribute the DG power reasonably to The associate editor coordinating the review of this manuscript and approving it for publication was Lei Chen . reduce the operation cost of MG [5], [6]. How to realize the optimal power allocation is discussed in this paper.
There are many methods to solve the economic optimal solution of MG, such as a new security-constrained multi-objective optimal dispatch [7], an interval multiobjective optimal scheduling [8], the Grey wolf optimization (GWO) [4], [9], particle swarm optimization (PSO) [10] and so on. The structure of MG is often flexible, and it will be adjusted according to the actual situation. New energy power generation, such as photovoltaic power generation and wind power generation, has great randomness and is greatly affected by weather factors. Therefore, if the optimization method is established under the fixed structure and mathematical model, it will be invalid because of the change of the above conditions. With the intention of making the networks of agents with switching topology control more flexible, the multi-agent consistency method has been widely used in recent years [11]- [15]. This method based on multi-agent consistency can realize the power sharing of MG adaptively. When the structure and load of MG change, MG will reach a new balance point and realize power sharing [16]- [19]. VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ Inspired by this method, by using the secondary control based on multi-agent consistency theory and GWO, the real-time power distribution of MG is realized. We have finished this part of the work in [20]. However, the secondary control method used in [20] is a kind of infinite-time convergence control method, including the multi-agent consensus theory used in the literatures mentioned above. When the structure of MG is changed, it is very important to improve the convergence rate of the system [21]. In order to realize the convergence of MG in finite time, this paper combines finite-time theory with multi-agent theory to construct a secondary controller, which makes the convergence time of MG exist supremum. This ensures the convergence speed of MG. Moreover, In order to obtain the optimal power distribution scheme and get the optimized rated power, it is necessary to use multi-objective optimization algorithm to reasonably allocate the power of MG according to the actual situation. There are many existing optimization methods, such as genetic algorithm (GA) [22], [23], bat algorithm (BA) [24], PSO [25], GWO [26], firefly optimization algorithm (FOA) [27], Moth-flame optimization algorithm (MFO) [28] etc. In our previous research results [20], it has been proved that GWO algorithm is faster and better than other algorithms. It is able to provide very competitive results of different benchmark functions compared with other well-known meta-heuristic techniques [20], [26]. However, the GWO has some shortcomings and its exploration and exploitation ability is insufficient. It is easy to produce local optimal solution and slow calculation speed. So GWO is improved in this paper to enhance its exploration and exploitation ability and improve the calculation speed and accuracy.
In this paper, based on the theories of multi-agent consistency and finite-time stability, an adaptive hierarchical control method considering generation cost is proposed. In order to achieve accurate power sharing and dynamic power allocation, the primary control adopts droop control, and the secondary control using adaptive virtual impedance is introduced to avoid the influence of line impedance mismatch. This can accurately achieve power sharing. The tertiary control adopts the improved gray wolf optimization (IGWO). The stability of the control strategy is proved by the theories of multi-agent consistency and finite-time stability. The validity of the method is verified in the MATLAB/SIMULINK environment.

II. SYSTEM STRUCTURE
The conventional droop control is usually used as the primary control, which can stabilize the voltage and frequency of the system [29]. The structure diagram of DG based on inverter is shown in Fig. 1.
When the line impedance of MG is inductive, the active and reactive power sharing could be achieved according to the droop characteristics of P/ω and Q/U .
The conventional droop controllers' theory is (1) where ω * i is the reference angular frequency output by the primary controller [30], U ref is the reference voltage value, P i and Q i are the measured active and reactive power, m i and n i are the droop coefficients, ω rate and U rate are rated frequency and voltage respectively.  Because the line impedance between DGs is out of proportion, the MG cannot achieve power sharing only by using droop control in practical application. Therefore, in order to realize power sharing accurately, the secondary control is needed.

A. SECONDARY CONTROL
In order to eliminate the influence of line impedance mismatch and realize power sharing accurately, the hierarchical control structure proposed in this paper is shown in Fig. 2.
The controller adjusts the component of the output voltage on the d-axis to make it equal to the voltage set-point [29]. From (1), we can get that where U dref and U qref are the d axis component and q axis component of U ref . By introducing m i P GWOi and n i Q GWOi terms, (1) can be rewritten as where u Pi , u Qi , u ωi and u Ui are the auxiliary control. P GWOi and Q GWOi are output values of tertiary controller. These parameters are discussed in detail in the next section.
When the power sharing of MG is realized, the following two equations hold [20].
where k p and k p are real numbers. In order to realize power sharing and adjust the frequency and voltage of DG to rated value, the auxiliary control u Qi u Ui , u Pi and u ωi are designed as shown in (7)-(10) according to the theories of multi-agent consistency and finite time.
where a ij is the communication weight. The neighbors set of node i is represented as to the reference, otherwise, b i = 0. |·| stands for absolute value. ψ Q , ψ U , ψ P and ψ ω are contiguous odd functions. sig(·) α = |·| α sgn(·), where sig(·) is the sign function. As can be seen from Fig. 2, the frequency amplitude set-point is as follows The voltage reference value is as follows where ξ U and ξ Q are design parameters, U Vir is the virtual voltage. U Vird and U Virq are the d axis component and q axis component of U Vir , respectively. By introducing the above secondary controller, the frequency, voltage and power of each DG can be converged effectively based on the property of multi-agent consistency theory. In this way, combined with the improved GWO described in the next section, the power scheduling of MG can be accurately realized.

B. IMPROVED GREY WOLF OPTIMIZATION
In the previous research results [20], we have successfully used GWO to optimize the power distribution of MG. The social hierarchy of grey wolves is divided into four levels, from high to low as alpha (α), beta (β), delta (δ) and omega (ω). Alpha wolves are the highest in the wolf pack. They are the leader of the wolf pack and other wolves must follow their instructions. The second level in the hierarchy of grey wolves is beta. The lowest ranking grey wolf is omega. They always have to submit to all the other dominant wolves [26]. However, the conventional GWO has some shortcomings, and its exploration and exploitation ability is poor. This is easy to produce local optimal solution and slow calculation speed. So GWO is improved in this paper to enhance its exploration and exploitation ability and improve the calculation speed and accuracy. IGWO is introduced in detail below.

1) ENCIRCLING PREY
Grey wolves encircle prey during the hunt. In this process, a grey wolf can update its position inside the space around the prey in any random location by using (15) and (16).
where S p is the position vector of the prey and S w indicates the position vector of a grey wolf, t indicates the current iteration, ξ and σ are the coefficient vectors which are calculated using the following equations where components of µ are linearly decreased from 2 to 0 over the course of iterations, r 1 and r 2 are random vectors between [0, 1]. However, the method of linear decline is not very exploratory, and it is easy to cause local optimal solution. Before searching for prey, we should increase the scope of its search. Therefore, this paper adopts the quadratic nonlinear decline strategy, i.e., convex function, as shown below.
where ii is the number of iterations, ii Max is the maximum number of iterations. With this method, the search range can be increased and the time when µ decreases is delayed

2) HUNTING
The hunt is guided by the alpha wolf. The beta and delta wolves participate in hunting occasionally. The mathematical equations of the hunting process is shown in (20)- (22). The principle can be referred to [26].
As shown in (22), the average of the current positions of the three levels of gray wolf is the target range of the next gray wolf search. However, if the better prey location is far away from the current location of the gray wolf, then the gray wolf may not search the location. This will lead to local optimal solution. In order to increase the ability of gray wolf to search prey and prevent local optimal solution, (22) is rewritten as where x + y = 1, x ∈ (0, 1] and y ∈ (0, 1] are the constant coefficients and are used to adjust the exploration and exploitation abilities of (15). S randi (t − 1) is the location of gray wolf randomly selected in the last search results. n is the number of gray wolves selected. In this paper, n is taken as 3. By using this method, we can effectively enhance the exploration ability of gray wolf and prevent the emergence of local optimal solution. The simulation results also show that the method is effective. Next, the rest of the hunt includes attacking prey and search for prey. For a detailed introduction of these two process, please refer to [26], which will not be repeated here.

3) CONSTRAINTS
When IGWO is used to optimize the power distribution of MG, the actual situation of MG should be considered. The details of this part can refer to our previous work [20]. Here is a brief introduction.
Considering the actual generation cost and rated power of each DG in MG, the objective function is constructed as follows.
where η and λ are weight coefficients, the f 1 is the generation cost function of MG. P optn and Q optn are the active power and reactive power respectively that should be generated by each DG after IGWO calculation. A i is the comprehensive cost coefficient. In order to facilitate the calculation and verify the effectiveness of the method, it is simplified and scaled [31].
The f 2 function is to consider the actual rated power of each DG to avoid the DG with large rated power generating less power and full load operation. The optimized total power of MG should be equal to the actual total power. There are In addition, the optimized DG output power should be less than the actual rated power of DG. There are 0 ≤ P opti ≤ P ratei , 0 ≤ Q opti ≤ Q ratei , i = 1, 2, . . . , n (28) When the active power and reactive power are all sharing, (29) and (30) are established. m GWO1 P opt1 = m GWO2 P opt2 = . . . = m GWOn P optn (29) n GWO1 Q opt1 = n GWO2 Q opt2 = . . . = n GWOn Q optn (30) where m GWOi and n GWOi are the active and reactive droop coefficients after calculation based on IGWO, respectively. Finally, the optimized rated power is derived from the actual rated power and the optimized power, as shown in (31)- (32). The optimized rated power is an intermediate variable and its function is to dynamically adjust the generating power of DG when the power sharing is realized.
, . . . , P raten P optn (31) The flow chart of power management of MG is depicted based on IGWO algorithm, as shown in Fig.3. In addition, in order to speed up the simulation, the IGWO module is triggered every time T GWO . The value of T GWO is adjusted according to the actual needs, and this paper sets T GWO to 2.5s.

C. ADAPTIVE VIRTUAL IMPEDANCE
After the introduction of secondary controller and tertiary controller, due to the fact that the line impedance of each DG is not proportional in practical application, it is necessary to deal with this situation. According to the energy conservation theorem, the active and reactive power output of DG are calculated in (33) and (34).
where E is the output voltage amplitude of inverter, U is the terminal voltage of DG, δ is the power angle, Z and θ are the magnitude and phase of the output impedance, respectively. This paper considers that the line impedance of MG is inductive. (35) can be obtained by (34) According to the properties of multi-agent consensus theory, there exists U → U rate with the passage of time. Combined with (1), there is However, the line impedance between each DG is not proportional, i.e., Q 1 Z 1 = Q 2 Z 2 = . . . = Q n Z n . Therefore, it is necessary to add compensation items in (36) to make (36) hold. We get (37).
where Z Viri is the adaptive virtual impedance. The structure of the adaptive virtual impedance module is shown in Fig. 4. L sta and R sta are static virtual inductor and static virtual resistance respectively, which are pre-set estimates based on line impedance. L Vir and R Vir are adaptive equivalent virtual inductor and equivalent virtual resistance respectively. k L and k R are proportional gains. The expression of L Vir and R Vir are Other parameters are shown in Fig. 4. The dual loop controller and droop controller work together to stabilize the frequency and voltage of DG. It is usually composed of voltage loop controller and current loop controller. For a detailed introduction of this part, please refer to [29], [30].

III. STEADY-STATE ANALYSIS
In this section, we prove that the control strategy proposed in this paper is stable. We assume that the communication network of MG is jointly-connected based on graph theory [32].
Theorem 1: The communication network of MG remains jointly-connected. Under the control algorithms (7) and (8), the voltage of each DG in MG can synchronize to the rated value in finite time. When the system is stable, the MG can get accurate reactive power sharing in finite time.
Theorem 2: The communication network of MG remains jointly-connected. Under the control algorithms (9) and (10), the frequency of each DG in MG can synchronize to the rated value in finite time. When the system is stable, the MG can get accurate active power sharing in finite time.
Proof of Theorem 1: Firstly, we prove that the MG can get accurate reactive power sharing in finite time.
In the first step, we prove that algorithm (7) is globally asymptotically stable. The Lyapunov function candidate is constructed as (40) is obtained by deriving (39).
Using Lemma 2.1 in [32], we can get (41) Based on LaSalle's Invariance principle, the zero equilibrium of (7) is globally asymptotically stable. It follows that ∀i = j, t → ∞, Q j Q GWOj − Q i Q GWOi → 0, eventually the reactive power of DG can synchronize to a same value under the regulation of GWO, i.e., In the second step, we prove that the control algorithm (7) is locally homogeneous of degree κ 1 = 2(α 1 − 1) < 0 with expansion coefficients (2, 2, . . . , 2) n .
Through the derivation and analysis of the first two steps, we can get that the control algorithm (7) is globally asymptotically stable and locally homogeneous. According to lemma 5 and lemma 6 in [33], the control algorithm (7) is globally finite-time stable, i.e., the nominal reactive power ( Q i Q Ratei , ∀i ∈ I ) can synchronize to a same value in finite time globally. The reactive power sharing is obtained.
Secondly, we prove that the voltage of DG can synchronize to the rated voltage under the control algorithm (8) in finite time. This part of the proof process is similar to the previous one, and will not be repeated here.
Proof of Theorem 2: The proofs of active power and frequency are similar to that of reactive power. Furthermore, the active power and frequency is stable in finite time and then the last three terms on the right side of (11) tend to be constant. So the frequency of DG becomes stable in finite time and is the same at each node when MG is in stable operation. The proof is completed.
Through the proof of the above two theorems, we can see that MG converges in finite time and finally obtains the power sharing accurately. In order to further explain that MG will converge in finite time, the supremum of convergence time is given by using the finite-time Lyapunov theorem. Let There must be a set of positive numbers to make the following equation hold according to (40), because ψ Q (·) is an odd function.
Because the communication network of MG remains jointly-connected, the eigenvalues of the Laplace matrix L VOLUME 8, 2020  satisfy (50) based on graph theory.
Using the same method, we can get the convergence time supremum of the control algorithms (8)-(10), i.e., T U , T P and T ω . Therefore, the convergence time of the whole MG can be expressed as The proof of MG convergence in finite time is completed. Finally, combined with (5) and (6), the active and reactive power are all sharing under the optimized rated power, there are where i = 1, 2, . . . , n, so that power can be managed dynamically by adjusting the optimized rated power.

IV. SIMULATION VALIDATION
In order to verify the effectiveness of the proposed method based on IGWO in this paper, we first compare it with other optimization algorithms, GWO, PSO, ALO and MFO. The simulation results are shown in Fig.5. The simulation parameters of each DG are shown in the tables (see Table 1 and Table 2 in APPENDIX). We set ψ Q , ψ U , ψ P and ψ ω to tanh(x). The results of (24) are shown in Fig.5 (a), and the results of the function F1, F2 and F3 in [26] are shown in Fig.5 (b), (c) and (d) respectively. As shown in Fig.5, the convergence speed and optimization results of IGWO are better than other optimization algorithms. This shows that the IGWO algorithm is effective.
The following situations of fixed communication topology and switching topology are considered to verify the effectiveness of the proposed control strategy. In the fixed communication topology, this paper calculates two cases, including load switching and cost coefficient change. The MG consists of four DGs and the communication topology diagram of MG are shown in Fig. 6.

A. FIXED COMMUNICATION TOPOLOGY
The MG system operates on islanded mode only with conventional droop control between 0-0.5s, and the secondary control is introduced at t = 0.5s. In the first case, the load 3 is plugged at t = 0s and removed at t = 3s. In order to verify the effectiveness of IGWO algorithm, IGWO begins to work at t = 5.5s, the simulation results are shown in Fig. 7. In the second case, the load 3 is removed at t = 0s and plugged at t = 3s, the simulation results are shown in Fig. 8. IGWO begins to work at t = 5.5s. The cost curves for the above two cases are shown in Fig. 9(a) and Fig. 9(b), respectively. The total simulation time is 8 seconds. As shown in Fig. 7 and Fig. 8, we can see that the reactive power sharing is not achieved only with conventional droop control before t = 0.5s. Under the action of the proposed secondary control, m GWOi P Magi and n GWOi Q Magi are all equal to each other, respectively. The active and reactive power are all sharing under the optimized rated power.
The cost curve based on the (25) is shown in Fig.9 (a) and Fig.9 (b), corresponding to Fig. 7 and Fig. 8, respectively. It can be seen that the cost of the first case decreases by 13.5% and the one of the second case decreases by 8.6% under IGWO. The hierarchical control strategy proposed in this paper can effectively reduce the generation cost of MG.

B. SWITCHING COMMUNICATION TOPOLOGY
The communication network of MG is shown in Fig. 10. The network remains jointly-connected. In the first case, the communication links between DG2 and DG3 are connected at t = 0s and disconnected at t = 3s, while the communication links between DG3 and DG4 are the same, i.e., DG3 is removed from the network. The simulation results are shown in Fig. 11. In the second case, the DG3 is removed at t = 0s and plugged back into MG at t = 3s, the simulation results are shown in Fig. 12. Similar to the previous section, IGWO was introduced at t = 5.5s. The total simulation time is 8 seconds.
As shown in Fig.11 and Fig.12, when DG3 is removed from MG and plugged back into MG, MG can still achieve power sharing. This makes MG very flexible. The cost curve based on (25) is shown in Fig.13 (a) and Fig.13 (b), corresponding to Fig. 11 and Fig. 12, respectively.
It can be seen that the cost of the first case decreases by 2.6% and the one of the second case decreases by 8.3% under IGWO. By comparing Fig.13 (a) and Fig.13 (b), we can find that the more DGs of MG, the more space for cost optimization. In practical applications, MG is usually composed of many DGs. Therefore, the control strategy proposed in this paper can greatly reduce the generation cost.

C. VARIABLE COST COEFFICIENT
In this section, we will discuss the influence of sudden change of cost coefficient on power distribution during MG operation. In this case, IGWO is started at t = 3s. The cost coefficient A 3 in (25) changes from 1$/W to 3$/W at t = 5.5s. IGWO works again at t = 5.5s. The total simulation time is 8 seconds. The simulation results are shown in Fig.14.
It can be seen from Fig.14 (a) and Fig.14 (b), when the generation cost of DG3 increases suddenly, the controller will automatically reduce the power output of DG3 to reduce the operation cost of MG. The power sharing can still be achieved in Fig.14 (c).
From the above examples, we can easily see that no matter how the load, structure of MG and cost coefficient change, MG achieves power sharing, and the operation cost is optimized by dynamically adjusting the optimized rated power.

V. CONCLUSION
In this paper, an adaptive hierarchical control method considering generation cost is proposed. The conclusions are as follows.
1) The secondary controller is constructed based on the theories of multi-agent consistency and finite-time stability, which makes the control of MG more flexible and reliable. The power sharing can be realized by this control method in finite time.
2) In order to achieve accurate power sharing and avoid the influence of mismatched line impedance, an adaptive virtual impedance module is introduced into the secondary controller to effectively solve the problem of line impedance mismatch. Finally, the accurate sharing of reactive power is realized.
3) GWO algorithm is used in the tertiary controller. In this paper, GWO algorithm is improved to effectively improve the exploration and exploitation ability of grey wolf and the calculation speed and quality of the tertiary controller. Combined with the secondary controller, the on-line real-time optimal power distribution of MG is achieved by dynamically optimizing the rated power.
4) The stability of MG is proved by the theories of multi-agent consistency and finite-time stability. By using the method proposed in this paper, it can be proved that the convergence time of MG has a supremum by the finite-time Lyapunov theorem, which ensures the convergence rate of the system. Ensuring convergence time is very important for the on-line real-time optimal power distribution of MG.
This paper studies a control strategy. The DGs used in this paper all adopt ideal DC power, and these DGs are renewable energy such as wind energy and solar energy in practical application. In addition, the communication delay is not considered in this paper. Therefore, the research of AC/DC hybrid power grid and communication delay are the focus of the author's future work.

APPENDIX
See Tables 1 and 2.