A Computationally E ffi cient Optimization Method for Battery Storage in Grid-connected Microgrids Based on a Power Exchanging Process

Battery storage (BS) sizing problems for grid-connected microgrids (GCμGs) commonly use stochastic scenarios to represent uncertain natures of renewable energy and load demand in the GCμG. Though taking a large number of stochastic scenarios into consideration can deliver a relatively accurate optimal result, it can also highly deteriorate the computational efficiency of the sizing problem. To make an accuracy-efficiency trade-off, a computationally efficient optimization method to optimize the BS capacities based on the power exchanging process of the GCμG is proposed in this paper. According to the imbalanced power of the GCμG, this paper investigates the power exchanging process between the GCμG, BS and external grid. Motivated by the BS dynamics, a forward/backward sweep-based energy management scheme is proposed based on the power exchanging process. A heuristic two-level optimization model is developed with sizing BS as the upper-level problem and optimizing the operational cost of the GCμG as the lower-level problem. The lower-level problem is solved by the proposed energy management scheme and the objective function of the upper-level is minimized by the pattern search (PS) algorithm. To validate the accuracy and computational efficiency of the proposed method, the numerical results are compared with the mixed integer linear programming (MILP) method. The comparison shows that the proposed method shares similar accuracy but is much more time-efficient than the MILP method.


Introduction
As one of the well-recognized approaches to mitigate climate change and restructure the global energy mix, microgrids integrate various types of distributed generation sources, such as photovoltaics (PV) and wind turbines (WT), to supply local loads effectively and economically [1,2].Microgrids can be designed as an AC type or DC type, and operate either in disconnection or connection mode with external grids [3][4][5].In particular, grid-connected microgrids (GCµGs) are a common network structure for the industrial zones and residential communities in urban areas regarding the backbone of external grids and the urgent need for renewable energy [6,7].A GCµG is commonly connected to the external grid via the dedicated transformer (DT) and purchases electricity based on time-of-use (TOU) prices [8].However, due to uncertain natures of renewable energy and load demand, it is a challenging task to maintain reliability and power quality for highly-penetrated GCµGs.Storage devices, such as battery storage systems (BSs), provide a feasible way to store excessive energy produced by renewable sources and supply local loads when needed.Clearly, an optimal sizing of the BS plays a crucial part in utilizing renewable energy efficiently, satisfying load demand economically and ensuring the reliability of GCµGs.
Generally, the BS sizing problem for microgrids can be formulated as an investment decision problem combined with an energy management optimization problem [9][10][11][12].For instance, reference [13] implements the mixed integer linear programming (MILP) method to optimize the BS capacity of microgrids with the reliability criterion being considered.Researchers use particle swarm optimization to develop the novel frequency control and demand response separately in reference [14] and reference [15] to ensure stability of microgrids, which are integrated into the BS capacity optimization model to minimize the total cost of the BS.In reference [16], the capacity of the vanadium redox battery for microgrids is optimized based on the proposed optimal scheduling analysis and cost-benefit analysis and then the optimization problem is used to solve the optimal energy management problem.A concept of mix mode energy management strategy combined three different types of operating strategies is used to determine the BS capacities for GCµGs in reference [17].A cost-benefit analysis-based BS capacity optimization framework is proposed in reference [18] which solves the MILP method.
Since the uncertain natures of renewable energy and load demand have significant impacts on the operation of microgrids when optimizing the BS capacities, a common way to characterize these uncertain natures is generating massive stochastic scenarios by sampling or building probability distribution based on historical operational data of renewable energy and load demand [19][20][21][22].The accuracy of the optimal results can be boosted with a large number of stochastic scenarios considered.However, increasing the number of stochastic scenarios may also lead to the boom of optimization variables.For instance, in terms of the MILP method, the number of binary variables is often used as an indicator of the computational difficulty [23].A BS capacity optimization problem considering over hundreds of stochastic scenarios would have tens of thousands of binary variables to deal with.This condition could spend dozens of hours obtaining the optimal results, or even worse, lead to no feasible solutions due to overburdened memory usage of computing equipment.To tackle this issue, a scenario reduction technique [24] is used to reduce the number of stochastic scenarios.This technique is conducive to mitigating the efficiency issues, but it could also neglect some low-probability but high-risk scenarios and accordingly, compromise the accuracy of the optimal results.
From the model point of view, it is the energy management optimization problem that needs to consider a large number of stochastic scenarios in order to represent uncertain natures of renewable energy and load demand in microgrids.Therefore, for those algorithms adopting the similar optimization framework, the dilemma of balancing accuracy and efficiency is still an open question to be answered.
To address this problem, instead of solving the BS sizing problem directly via mathematic tools, this paper starts from the perspective of imbalanced power of renewable energy and load demand to study the power exchanging process of the GCµG with the BS and the external grid.Then, we take one of the stochastic scenarios as an example to quantify the power exchanging process with consideration of power limits of the BS and the DT.On this basis, a BS energy management scheme using the forward/backward sweep technique is proposed with consideration of the TOU prices.We solve the BS sizing problem by establishing a heuristic two-level optimization framework using the proposed energy management scheme.
The major contribution of this paper can be summarized as follows.

1.
Based on the imbalanced power of the GCµG, this paper investigates the power exchanging process of the GCµG with the BS and external grid.The dispatching strategies for the BS are derived from the power exchanging process analysis and then are quantified considering the power ratings of the BS and the DT.

2.
Motivated by the dynamics of the BS, a BS energy management scheme using the forward/backward sweep technique is proposed.This energy management scheme is able to obtain the optimal dispatching results of the BS rapidly in the context of the TOU prices.

3.
A heuristic two-level optimization model for sizing BS is developed using the pattern search (PS) algorithm and the proposed energy management scheme.The comparison with the mixed integer linear programming (MILP) method, which is a common approach used to address microgrid planning problems, shows that the proposed method has a similar degree of accuracy and much better computational performance.
The rest of the paper is organized as follows: Section 2 analyzes the power exchanging process of the GCµG with the BS and external grid.The optimization model for sizing the BS is summarized in Section 3. Section 4 presents the quantification of the possible dispatching strategies for the BS, followed by the forward/backward sweep-based energy management scheme proposed in Section 5. A two-level optimization framework using the proposed energy management scheme is illustrated in Section 6. Results of the numerical simulation as well as the comparison with the MILP method are presented in Section 7. Finally, Section 8 concludes the paper.

Power Exchanging Process of GCµG
Due to the uncertain nature of renewable sources (e.g., PV and WT) and load demand, it could easily result in power imbalance issues, assuming that a microgrid has no BSs installed or no connections with external grids.The imbalanced power caused by such an uncertain nature can be formulated as the net power of renewable sources and load demand, namely where ∆P st is the imbalanced power of the microgrid; P st RE = P st PV + P st WT , representing the total power of the PV and WT; P st LD is the load demand; s and t denote the indices of stochastic scenarios and time instance, respectively.
In order to completely satisfy ∆P st , the GCµG needs to absorb energy from or transfer energy to the BS or the external grid.The power exchanging process of the GCµG with the BS and external grid is depicted in Figure 1.
Energies 2019, 11, x FOR PEER REVIEW 3 of 20 3. A heuristic two-level optimization model for sizing BS is developed using the pattern search (PS) algorithm and the proposed energy management scheme.The comparison with the mixed integer linear programming (MILP) method, which is a common approach used to address microgrid planning problems, shows that the proposed method has a similar degree of accuracy and much better computational performance.
The rest of the paper is organized as follows: Section 2 analyzes the power exchanging process of the GCμG with the BS and external grid.The optimization model for sizing the BS is summarized in Section 3. Section 4 presents the quantification of the possible dispatching strategies for the BS, followed by the forward/backward sweep-based energy management scheme proposed in Section 5. A two-level optimization framework using the proposed energy management scheme is illustrated in Section 6. Results of the numerical simulation as well as the comparison with the MILP method are presented in Section 7. Finally, Section 8 concludes the paper.

Power Exchanging Process of GCμG
Due to the uncertain nature of renewable sources (e.g., PV and WT) and load demand, it could easily result in power imbalance issues, assuming that a microgrid has no BSs installed or no connections with external grids.The imbalanced power caused by such an uncertain nature can be formulated as the net power of renewable sources and load demand, namely In order to completely satisfy st P Δ , the GCμG needs to absorb energy from or transfer energy to the BS or the external grid.The power exchanging process of the GCμG with the BS and external grid is depicted in Figure 1.Clearly, there are three different situations that can be observed from Figure 1: 1.If 0 Δ = st P , it indicates that the output of renewable sources is able to exactly meet the load demand of the GCμG and no additional power needs to be exchanged with the BS and external grid.Clearly, there are three different situations that can be observed from Figure 1: 1.
If ∆P st = 0, it indicates that the output of renewable sources is able to exactly meet the load demand of the GCµG and no additional power needs to be exchanged with the BS and external grid.

2.
If ∆P st > 0, the imbalanced power presents a generation-like feature.It implies that there is excessive generation (EG) in the GCµG which requires the BS or the external grid to absorb.In Figure 1, P st RM denotes the part of EG that could be transferred to the external grid.Both P st RB and P st TRB denote the part of EG that could be consumed by the BS, the difference of which will be further discussed in the following sections.When the part of EG exceeds the capacities of the BS and the DT that connects the GCµG and the external grid, this part of EG, namely P st IRC , will inevitably be curtailed.

3.
If ∆P st ≤ 0, the imbalanced power presents a load-like feature.It implies that the GCµG has excessive load (EL) that should be supplied by the BS or the external grid.In Figure 1, P st ML denotes the part of EL being supplied by the external grid.Both P st BL and P st BTL denote the part of EL being supplied by the BS, whose differences will be discussed in the following sections as well.Also, the part of EL that exceeds the capacities of the BS and the DT, namely P st ILL , will inevitably be dumped.
Additionally, the BS can exchange energy with the external grid to adjust the remaining energy by operating in charging and discharging modes, i.e., P st MB and P st BM .

Battery Storage
The BS dynamics can be formulated as where E st B is the remaining energy stored in the BS; P st B is the available output of the BS; E B and E B are the upper bound and lower bound of the charging-discharging process and set to be 90% and 10% of the BS energy rating E B , respectively [25]; the charging-discharging efficiency η = η 0 , charging 1/η 0 , discharging where η 0 = 0.95 for a sodium-sulfur (NaS) BS [26].
From Figure 1, the possible output of P st B can be given by Due to the power limits of the BS, P st B needs to satisfy the following constraint where P B is the BS rating power.Besides, the initial energy constraint is expressed as where E Bini is set as 50% of E B [27].

Dedicated Transformer
In Figure 1, the processes of the GCµG buying electricity from and selling electricity to the external grid can be separately formulated as Since the GCµG is connected via the DT with the external grid, P st Mb and P st Ms needs to meet the power limit constraint of the DT, i.e.,

−P Mb ≤ P st
Mb ≤ 0 0 ≤ P st Ms ≤ P Ms (9) where P Mb = P DT and P DT is the rating power of the DT; generally, P Ms is often less than P Mb , aiming at reducing the amount of energy transferred from the GCµG to the external grid.

Objective Function
In this section, a two-level optimization framework is developed to determine the BS capacities for the GCµG.

Upper Level
The upper level of the BS sizing problem is solved by minimizing both the investment cost of the BS and the operational cost of the microgrid, which can be expressed as where C B represents the investment cost of the BS and C Op is the operational cost.Since the operational cost of the microgrid is calculated over 24 h in this paper, the one-time investment cost of the BS is required to be normalized as [28] where k = r(1 + r) l /[(1 + r) l − 1] and r denotes the interest rate and l is the expected lifetime of the BS.ϕ EC BS , ϕ MC BS and ϕ PC BS represent the capital cost of the energy rating, maintenance and power rating of the BS.

Lower Level
The objective of the lower level is to minimize the operational cost of the GCµG, which is defined as the expected daily cost considering all stochastic scenarios plus the fixed charges of the two-part tariff scheme, namely min where ρ(s) and C s Op denote the probability and operational cost of the sth stochastic scenario, respectively.Considering that China currently implements a two-part tariff scheme for electricity pricing, (12) consists of the fixed charges and run charges [29].Clearly, the term s∈S ρ(s)C s Op is the run charges related to the actual energy consumed by the GCµG.The term C DT is the fixed charges that depends on the maximum capacity of the DT the GCµG has declared to the utilities, which can be expressed as where ϕ DT is the constant electricity price related to the declared DT capacity, which is set to 23 CNY/kW per month.

Quantification of Power Exchanging Process
From ( 5) and ( 9), it can be noted that the power of the GCµG exchanging with the external grid and BS are limited by the power ratings of the BS and DT, namely P B , P Ms and P Mb .Figure 2 shows the imbalanced power curve of an arbitrary stochastic scenario.If these three capacity parameters are taken into consideration in Figure 2, the imbalanced power curve can be dissected into several areas.
shown in Figure 2. The excessive generation in area ① and the excessive load in area ⑧ are the energy inevitably being curtailed or dumped, which can be separately calculated by where [ ] + ⋅ denotes the maximum value between 0 and the given value and [ ] − ⋅ denotes the minimum value between 0 and the given value.Since the power in area ③ and area ⑥ is beyond the BS power rating but well within the DT power rating, these two portions of energy can be consumed or supplied by the external grid, which can be separately calculated by

RM
Ms B

[min( , ) ]
st st E P P P t ML Ms B [max( , ) ] st st E P P P t It can be noted that ( 14) to (17) show no relevance with the dispatching process of the BS.
In terms of the excessive generation in area ②, this part of energy is not allowed to be transferred to the external grid via the DT since it exceeds Ms P .However, the BS power rating can still cover this part of energy which, as a result, should be preferentially consumed by the BS on condition that there is sufficient energy capacity in the BS; or else, it will further increase the amount of renewable energy curtailment.This part of energy is defined as the top-prioritized renewable energy (TR).Due to the similar reasons, the excessive load in area ② cannot be supplied by the external grid but rather by the BS or else, it will further increase the amount of load loss.This part of energy is defined as the top-prioritized load demand (TL).The energy of TR and TL can be separately given by Due to the limited capacities of the BS and DT, the part of imbalanced power that exceeds the total sum of their capacities cannot be consumed or supplied, which refers to area 1 and area 8 shown in Figure 2. The excessive generation in area 1 and the excessive load in area 8 are the energy inevitably being curtailed or dumped, which can be separately calculated by where [•] + denotes the maximum value between 0 and the given value and [•] − denotes the minimum value between 0 and the given value.Since the power in area 3 and area 6 is beyond the BS power rating but well within the DT power rating, these two portions of energy can be consumed or supplied by the external grid, which can be separately calculated by It can be noted that ( 14) to (17) show no relevance with the dispatching process of the BS.
In terms of the excessive generation in area 2 , this part of energy is not allowed to be transferred to the external grid via the DT since it exceeds P Ms .However, the BS power rating can still cover this part of energy which, as a result, should be preferentially consumed by the BS on condition that there is sufficient energy capacity in the BS; or else, it will further increase the amount of renewable energy curtailment.This part of energy is defined as the top-prioritized renewable energy (TR).Due to the similar reasons, the excessive load in area 2 cannot be supplied by the external grid but rather by the BS or else, it will further increase the amount of load loss.This part of energy is defined as the top-prioritized load demand (TL).The energy of TR and TL can be separately given by For clarity and analysis convenience, we use the symbol ε to express the energy that the BS needs to consume or supply.
The excessive generation in area 4 and excessive load in area 5 can be covered by both the power ratings of the BS and DT.From the perspective of economical operation, these two parts of energy should be consumed or supplied by the BS first if the BS has sufficient remaining energy.Hence, the energy in area 4 and 5 can be expressed as Also, the external grid can supply the BS for the charging process, which can be represented by In (22), the condition of ∆P st > 0 means ε st MB should subtract the energy the microgrid supply to the BS if any whereas the condition of ∆P st ≤ 0 means ε st MB should subtract the energy the external grid supplies to the microgrid if any.
Similarly, the BS is allowed to be discharged to send power back to the external grid, which is given by (23) shows that when ∆P st ≤ 0, the BS is only permitted to supply load demand of GCµG instead of sending power to the external grid.Additionally, when considering the electricity prices, ε st BL plays a significant role in reducing the cost of buying electricity from the external grid while ε st MB would increase it.In the context of the TOU electricity prices, ε st BL and ε st MB can be further formulated as (24) and (25), respectively, according to different time periods.
where n ∈ N = o f f , mid, on ; off, mid and on represent the off-peak, mid-peak and on-peak periods, respectively.

Forward/Backward Sweeping-Based BS Energy Management Scheme
Equations ( 18) to ( 25) demonstrate the possible power exchanging processes of the BS with the GCµG and the external grid.Since the TOU electricity price has a vital impact on the operational cost of the GCµG in different time periods, Equations ( 18) to (25) can actually be regarded as the BS dispatching approaches with various levels of electricity price.According to the aforementioned discussions in Section 4, Table 1 lists these dispatching approaches sorted from high to low by price.To limit the amount of energy delivered from the BS or the GCµG to the external grid as much as possible, the price of selling electricity should be necessarily lower than buying electricity.As a whole, economically dispatching the BS can lead to a cost-effective operation of the GCµG.
Figure 3 is the schematic of the BS dynamics based on (2), which shows that the remaining energy stored in the BS at any time instance is dependent on both the power output and the remaining energy of the BS at the previous time instance.Due to the initial energy constraint of ( 6), the BS remaining energy must restore itself to the same initial value either at the beginning or at the end of each day.
dispatching approaches with various levels of electricity price.According to the aforementioned discussions in Section 4, Table 1 lists these dispatching approaches sorted from high to low by price.
To limit the amount of energy delivered from the BS or the GCμG to the external grid as much as possible, the price of selling electricity should be necessarily lower than buying electricity.As a whole, economically dispatching the BS can lead to a cost-effective operation of the GCμG.2), which shows that the remaining energy stored in the BS at any time instance is dependent on both the power output and the remaining energy of the BS at the previous time instance.Due to the initial energy constraint of ( 6), the BS remaining energy must restore itself to the same initial value either at the beginning or at the end of each day.

Forward Sweep
Ideally, the BS is required to absorb the excessive power from renewable sources and supply TL and on-peak load of the GCμG, according to the BS remaining energy capacity.In this way, the GCμG can take full advantage of renewable sources and satisfy local load demand with less dependence on the external grid and less cost of purchasing electricity.The maximum energy that the BS needs to absorb or release in this case is given by Motivated by the BS dynamics mentioned above, a computationally efficient energy management scheme is developed based on the forward/backward sweep technique.Before elaborating on the proposed energy management scheme, we summarize the framework of the forward/backward sweep process in Figure 4.The forward sweep is conducted to initialize the BS remaining energy to preferentially consume TR or supply TL and on-peak load while the backward sweep is used to check if the BS remaining energy at the end of the day restores to the initial values.Finally, in the correction step, it checks separately whether the GCµG handles TL and TR completely.
dispatching approaches with various levels of electricity price.According to the aforementioned discussions in Section 4, Table 1 lists these dispatching approaches sorted from high to low by price.
To limit the amount of energy delivered from the BS or the GCμG to the external grid as much as possible, the price of selling electricity should be necessarily lower than buying electricity.As a whole, economically dispatching the BS can lead to a cost-effective operation of the GCμG.2), which shows that the remaining energy stored in the BS at any time instance is dependent on both the power output and the remaining energy of the BS at the previous time instance.Due to the initial energy constraint of ( 6), the BS remaining energy must restore itself to the same initial value either at the beginning or at the end of each day.Motivated by the BS dynamics mentioned above, a computationally efficient energy management scheme is developed based on the forward/backward sweep technique.Before elaborating on the proposed energy management scheme, we summarize the framework of the forward/backward sweep process in Figure 4.The forward sweep is conducted to initialize the BS remaining energy to preferentially consume TR or supply TL and on-peak load while the backward sweep is used to check if the BS remaining energy at the end of the day restores to the initial values.Finally, in the correction step, it checks separately whether the GCμG handles TL and TR completely.

Forward Sweep
Ideally, the BS is required to absorb the excessive power from renewable sources and supply TL and on-peak load of the GCμG, according to the BS remaining energy capacity.In this way, the GCμG can take full advantage of renewable sources and satisfy local load demand with less dependence on the external grid and less cost of purchasing electricity.The maximum energy that the BS needs to absorb or release in this case is given by

Forward Sweep
Ideally, the BS is required to absorb the excessive power from renewable sources and supply TL and on-peak load of the GCµG, according to the BS remaining energy capacity.In this way, the GCµG can take full advantage of renewable sources and satisfy local load demand with less dependence on the external grid and less cost of purchasing electricity.The maximum energy that the BS needs to absorb or release in this case is given by Take ε st Imax into consideration and substitute ( 26) into (2), then the BS dynamics can be rewritten as Energies where i = {I, II, III}; I, II and III denote the forward sweep, backward sweep and correction step, respectively.
In the forward sweep, the remaining energy in the BS at each time instance, namely E st B , can be obtained as t gradually increases to T, as depicted in Figure 5. ) where i = {I, II, III}; I, II and III denote the forward sweep, backward sweep and correction step, respectively.
In the forward sweep, the remaining energy in the BS at each time instance, namely B st E , can be obtained as t gradually increases to T, as depicted in Figure 5.

Backward Sweep
As stated in ( 6), the remaining energy stored in the BS at the end of the day should restore to the initial value to guarantee sufficient energy for the next day.However, the forward sweep does not contain this initial energy constraint and therefore, the BS remaining energy at time T calculated in the forward sweep may not be able to restore to the initial value.To measure the difference between the BS remaining energy at time T and the initial value, i.e., B sT E and Bini E , an index called remaining energy deviation is defined as follows Bini B If 0 s λ > , it indicates that the BS has over-released energy to supply load demand and hence, it is necessary to increase the amount of generation to consume or decrease the amount of load demand to supply to eliminate the remaining energy deviation.In contrast, the situation when s λ is less than zero indicates the BS has overconsumed energy generated by renewable sources and hence, for the elimination of the remaining energy deviation, it should consume less renewable energy or supply more load demand.To this end, we implement the backward sweep regarding the dispatching approaches listed in Table 1, which helps to eliminate s λ rapidly and have as small an impact on the dispatching results obtained in the forward sweep as possible.

Backward Sweep
As stated in ( 6), the remaining energy stored in the BS at the end of the day should restore to the value to guarantee sufficient energy for the next day.However, the forward sweep does not contain this initial energy constraint and therefore, the BS remaining energy at time T calculated in the forward sweep may not be able to restore to the initial value.To measure the difference between the BS remaining energy at time T and the initial value, i.e., E sT B and E Bini , an index called remaining energy deviation is defined as follows If λ s > 0, it indicates that the BS has over-released energy to supply load demand and hence, it is necessary to increase the amount of generation to consume or decrease the amount of load demand to supply to eliminate the remaining energy deviation.In contrast, the situation when λ s is less than zero indicates the BS has overconsumed energy generated by renewable sources and hence, for the elimination of the remaining energy deviation, it should consume less renewable energy or supply more load demand.To this end, we implement the backward sweep regarding the dispatching approaches listed in Table 1, which helps to eliminate λ s rapidly and have as small an impact on the dispatching results obtained in the forward sweep as possible.
Figure 6 presents the basic process of the backward sweep where with t decreasing from T − 1 to 0, the BS remaining energy adds ε st Bwk sequentially and then update the remaining energy from t to T.

The principle to select ε st
Bwk is presented in Table 2.The maximum energy that the BS needs to absorb or release in the backward sweep is given by Take Imax st ε into consideration and substitute ( 26) into (2), then the BS dynamics can be rewritten min( , max( , )) where i = {I, II, III}; I, II and III denote the forward sweep, backward sweep and correction step, respectively.
In the forward sweep, the remaining energy in the BS at each time instance, namely B st E , can be obtained as t gradually increases to T, as depicted in Figure 5.

Backward Sweep
As stated in ( 6), the remaining energy stored in the BS at the end of the day should restore to the initial value to guarantee sufficient energy for the next day.However, the forward sweep does not contain this initial energy constraint and therefore, the BS remaining energy at time T calculated in the forward sweep may not be able to restore to the initial value.To measure the difference between the BS remaining energy at time T and the initial value, i.e., B sT E and Bini E , an index called remaining energy deviation is defined as follows Bini B If 0 s λ > , it indicates that the BS has over-released energy to supply load demand and hence, it is necessary to increase the amount of generation to consume or decrease the amount of load demand to supply to eliminate the remaining energy deviation.In contrast, the situation when s λ is less than zero indicates the BS has overconsumed energy generated by renewable sources and hence, for the elimination of the remaining energy deviation, it should consume less renewable energy or supply more load demand.To this end, we implement the backward sweep regarding the dispatching approaches listed in Table 1, which helps to eliminate s λ rapidly and have as small an impact on the dispatching results obtained in the forward sweep as possible.Table 2. Priorities of the dispatching approaches in the backward sweep.27) to obtain the remaining energy at t + 1 time instance and then sequentially update the remaining energy from t + 2 to T as well as calculate λ s .If λ s flips, which means the value of the λ s flips from positive to negative and vice versa, (29) should be rewritten as (30) and recalculate the BS remaining energy from t + 1 to T. If not, let t = t − 1 and repeat the calculation process.If t = 0, it implies the end of the k th backward sweep process and then, let k = k + 1 and start another backward sweep process with the ε st Bwk+1 .The flowchart of the backward sweep is summarized in Figure 7.As shown in Figure 7, the maximum value of k in the back sweep is set to 5 according to Table 2. is summarized in Figure 7.As shown in Figure 7, the maximum value of k in the back sweep is set to 5 according to Table 2.At the end of each backward sweep process or when λ s flips, the operational cost of the kth backward sweep process is given by where

Rank Order (k)
Consequently, the operational cost in the backward process can be written as

Correction Step
The backward sweep regulates the power exchanging process of the BS with the external grid and the GCµG to satisfy the initial energy constraint shown in (6).However, it cannot yet ensure the GCµG to sufficiently consume the TR and supply the TL.Let the unhandled parts of the TR and TL be expressed as where If Γ s TR or Γ s TL is non-zero, it could further deteriorate energy curtailment or load loss issues of the GCµG.To address these problems, the BS should either consume more generation or supply less load (for the unhandled TR), or supply more load or consume less generation (for the unhandled TL).This process is defined as the correction step.
Similar to the backward sweep, the correction step calculates backward the BS remaining energy from time T to 0 with a correction of ε st Mdk .The principle to select ε st Mdk is presented in Table 3.The maximum energy that the BS needs to absorb or release in the backward sweep is given by Table 3. Priorities of the dispatching approaches in the correction step.

Rank Order (k) TR TL
Similarly, substitute ε st IIImax into (27) to obtain the remaining energy at t + 1 time instance and then sequentially update the remaining energy from t + 2 to T as well as calculate λ s .If λ s is non-zero, (37) should be rewritten as (38) and recalculate the BS remaining energy from t + 1 to T. Then let k = k + 1 and start another correction process with the ε st Mdk+1 .The flowchart of the correction step is summarized in Figure 8.As shown in Figure 8, the maximum value of k in the correction step is set to 4 according to Table 3.

Solution Algorithm
The framework of the two-level BS sizing problem for the GCμG is shown in Figure 9.The upper level aims at minimizing the total cost of the GCμG, namely (10), to obtain the optimal power and energy ratings of the BS.The PS algorithm is introduced to solve the upper level, the details of which can be found in reference [30].The inner level adopts the proposed energy management scheme to minimize the operational cost of each stochastic scenario and returns the expected operational cost At the end of each correction process, the corresponding operational cost is calculated by where

Solution Algorithm
The framework of the two-level BS sizing problem for the GCµG is shown in Figure 9.The upper level aims at minimizing the total cost of the GCµG, namely (10), to obtain the optimal power and energy ratings of the BS.The PS algorithm is introduced to solve the upper level, the details of which can be found in reference [30].The inner level adopts the proposed energy management scheme to minimize the operational cost of each stochastic scenario and returns the expected operational cost calculated using (41) to the upper level to continue the execution of the PS algorithm.The main steps of the proposed method are briefly summarized as follows.(1) Generate stochastic scenarios via the k-means method.Initialize the parameters of the proposed method as well as the capacities of the BS and DT.(2) Set the current capacities of the BS and DT as the starting point of the PS algorithm.Construct the direction vectors and create the mesh points accordingly.(3) Calculate the investment cost for each mesh point.(4) With regard to each mesh point, obtain the expected operational cost using (12) after optimizing (41) for each stochastic scenario using the proposed energy management scheme.Then, return the expected operational cost of each mesh point to the upper level.
(5) Evaluate the mesh points based on the total cost of each mesh point.Then, update the current capacities of the BS and DT.(6) If none of the termination criterion is reached, adjust the mesh size and return to (2); otherwise, output the current capacities of the BS and DT as the optimal results and stop the execution.(1) Generate stochastic scenarios via the k-means method.Initialize the parameters of the proposed method as well as the capacities of the BS and DT.(2) Set the current capacities of the BS and DT as the starting point of the PS algorithm.Construct the direction vectors and create the mesh points accordingly.(3) Calculate the investment cost for each mesh point.(4) With regard to each mesh point, obtain the expected operational cost using (12) after optimizing (41) for each stochastic scenario using the proposed energy management scheme.Then, return the expected operational cost of each mesh point to the upper level.
(5) Evaluate the mesh points based on the total cost of each mesh point.Then, update the current capacities of the BS and DT.(6) If none of the termination criterion is reached, adjust the mesh size and return to (2); otherwise, output the current capacities of the BS and DT as the optimal results and stop the execution.

Simulation Setup
The basic structure of the studied GCµG is shown in Figure 10, including local loads with maximum value of 500 kW and a renewable generation system composed of 250 kW PV and 750 kW WT.The parameters of the BS are listed in Table 4 and the interest rate is set to 6%.The power and energy ratings of the BS and the DT capacity declared to the utilities are the major decision variables to be optimized.

Simulation Setup
The basic structure of the studied GCμG is shown in Figure 10, including local loads with maximum value of 500 kW and a renewable generation system composed of 250 kW PV and 750 kW WT.The parameters of the BS are listed in Table 4 and the interest rate is set to 6%.The power and energy ratings of the BS and the DT capacity declared to the utilities are the major decision variables to be optimized.The TOU electricity price of Guangzhou city used in the numerical simulations is presented in Table 5.The price of selling electricity is assumed to be 0.3 CNY/kW h.Both the penalties of curtailing renewable energy and dumping loads should be set larger enough, in order to avoid renewable energy curtailment and load loss as much as possible [31].On this basis, the penalties are set to 150 CNY/kW h.This paper implements the proposed optimization method using MATLAB in a laptop with a Core i7-6700 CPU and 8 G memory.Additionally, (2) to ( 13) can also be formulated as a MILP model, which is solved via CPLEX in the same laptop and used to compare with the propose optimization method.

Results and Discussion
To validate the accuracy and the computational efficiency of the proposed method in comparison with the MILP method, we generate 200 stochastic scenarios via the k-means technique [32] using the historical data of WT, PV and load demand and conduct these two methods with the same scenarios.To further analyze the impact of the scenario number on the accuracy and the computational efficiency of the optimization problem, a scenario reduction technique in reference [24] is utilized to aggregate the generated scenarios into 30, 50, 100 and 150 scenarios.The TOU electricity price of Guangzhou city used in the numerical simulations is presented in Table 5.The price of selling electricity is assumed to be 0.3 CNY/kW h.Both the penalties of curtailing renewable energy and dumping loads should be set larger enough, in order to avoid renewable energy curtailment and load loss as much as possible [31].On this basis, the penalties are set to 150 CNY/kW h.This paper implements the proposed optimization method using MATLAB in a laptop with a Core i7-6700 CPU and 8 G memory.Additionally, (2) to ( 13) can also be formulated as a MILP model, which is solved via CPLEX in the same laptop and used to compare with the propose optimization method.

Results and Discussion
To validate the accuracy and the computational efficiency of the proposed method in comparison with the MILP method, we generate 200 stochastic scenarios via the k-means technique [32] using the historical data of WT, PV and load demand and conduct these two methods with the same scenarios.
To further analyze the impact of the scenario number on the accuracy and the computational efficiency of the optimization problem, a scenario reduction technique in reference [24] is utilized to aggregate the generated scenarios into 30, 50, 100 and 150 scenarios.

Accuracy Comparison
Table 6 lists the optimal capacities obtained by the proposed method and the MILP method.Figure 11 presents the daily total cost of the GCµG, considering different numbers of stochastic scenarios.6 lists the optimal capacities obtained by the proposed method and the MILP method.Figure 11 presents the daily total cost of the GCμG, considering different numbers of stochastic scenarios.
From the optimal capacities point of view, the optimal capacities of these two methods are nearly the same since the results obtained using the proposed method slightly differ from those obtained using the MILP model by 0.3 kW (kW h) to 4 kW (kW h).In addition, the daily total cost shown in Figure 11 also proves that the results obtained by the proposed method and the MILP method are very close.In general, the proposed method shares similar accuracies with the MILP method.In terms of the number of stochastic scenarios, if let the case with 200 stochastic scenarios be the base case, the daily total cost and the optimal capacities of the cases with 150 and 100 stochastic scenarios have subtle differences compared with the base case.Nevertheless, these differences are From the optimal capacities point of view, the optimal capacities of these two methods are nearly the same since the results obtained using the proposed method slightly differ from those obtained using the MILP model by 0.3 kW (kW h) to 4 kW (kW h).In addition, the daily total cost shown in Figure 11 also proves that the results obtained by the proposed method and the MILP method are very close.In general, the proposed method shares similar accuracies with the MILP method.
In terms of the number of stochastic scenarios, if let the case with 200 stochastic scenarios be the base case, the daily total cost and the optimal capacities of the cases with 150 and 100 stochastic scenarios have subtle differences compared with the base case.Nevertheless, these differences are still tolerable.However, as the number of stochastic scenarios continues to decrease, there are relatively large differences of the optimal results among the cases with 30 and 50 stochastic scenarios and the base case.The number of stochastic scenarios is a crucial factor that determines how well stochastic

Conclusions
In this paper, we investigate the power exchanging process of the GCµG with the BS and the external grid and propose a forward/backward sweep-based energy management scheme.A heuristic two-level optimization method is established using the proposed energy management scheme and the PS algorithm to determine the optimal capacities of the BS efficiently.To validate the accuracy and computational efficiency of the proposed optimization method, the numerical simulation results are compared with those calculated by the MILP method.The result analysis and comparison show that the increasing number of stochastic scenarios can boost the accuracy of the planning results but significantly slow down the calculation process when using the MILP method, while the proposed method requires much less time to deliver relatively accurate results.Therefore, it can be concluded that the proposed method outperforms the MILP method in terms of computational efficiency and has similar accuracy.Also, the study case comparing different two-part tariff schemes demonstrates that the GCµG can operate more economically when considering the transformer capacity based scheme than when considering the maximum load based scheme.

Figure 1 .
Figure 1.Illustration of the power exchanging process of the GCμG with the BS and the external grid.

Figure 1 ,
Figure 1, RM st P denotes the part of EG that could be transferred to the external grid.Both RB st P

Figure 1 .
Figure 1.Illustration of the power exchanging process of the GCµG with the BS and the external grid.

Figure 2 .
Figure 2. The imbalanced power curve of a stochastic scenario dissected by the power ratings of the BS and DT.

Figure 2 .
Figure 2. The imbalanced power curve of a stochastic scenario dissected by the power ratings of the BS and DT.

Figure 3
Figure3is the schematic of the BS dynamics based on(2), which shows that the remaining energy stored in the BS at any time instance is dependent on both the power output and the remaining energy of the BS at the previous time instance.Due to the initial energy constraint of (6), the BS remaining energy must restore itself to the same initial value either at the beginning or at the end of each day.

Figure 3 .
Figure 3. Illustration of the BS dynamics.

Figure 4 .
Figure 4.The framework of the forward/backward sweep process.

Figure 3 .
Figure 3. Illustration of the BS dynamics.

Figure 3
Figure3is the schematic of the BS dynamics based on(2), which shows that the remaining energy stored in the BS at any time instance is dependent on both the power output and the remaining energy of the BS at the previous time instance.Due to the initial energy constraint of (6), the BS remaining energy must restore itself to the same initial value either at the beginning or at the end of each day.

Figure 3 .
Figure 3. Illustration of the BS dynamics.

Figure 4 .
Figure 4.The framework of the forward/backward sweep process.

Figure 4 .
Figure 4.The framework of the forward/backward sweep process.

Figure 5 .
Figure 5. Illustration of the forward sweep.

Figure 6 Figure 6 .
Figure 6.Illustration of the backward sweep.

Figure 5 .
Figure 5. Illustration of the forward sweep.

Figure 5 .
Figure 5. Illustration of the forward sweep.

Figure 6 Figure 6 .
Figure 6.Illustration of the backward sweep.Figure 6. Illustration of the backward sweep.

Figure 6 .
Figure 6.Illustration of the backward sweep.Figure 6. Illustration of the backward sweep.
to obtain the remaining energy at t + 1 time instance and then sequentially update the remaining energy from t + 2 to T as well as calculate s λ .If s λ flips, which means the value of the s λ flips from positive to negative and vice versa, (29) should be rewritten as (30) and recalculate the BS remaining energy from t + 1 to T. If not, let t = t − 1 and repeat the calculation process.If t = 0, it implies the end of the kth backward sweep process and then, let k = k + 1 and start another backward sweep process with the Bw 1 st k ε + .The flowchart of the backward sweep

Figure 7 .Table 2 .Figure 7 .
Figure 7.The flowchart of the backward sweep.Table 2. Priorities of the dispatching approaches in the backward sweep.

Figure 8 .Table 3 .
Figure 8.The flowchart of the correction step.Table 3. Priorities of the dispatching approaches in the correction step.Rank Order (k) TR TL Md st k ε

Figure 8 .
Figure 8.The flowchart of the correction step.
calculated using (41) to the upper level to continue the execution of the PS algorithm.The main steps of the proposed method are briefly summarized as follows.

Figure 9 .
Figure 9.The flowchart of the proposed optimization method.

Figure 9 .
Figure 9.The flowchart of the proposed optimization method.

Figure 10 .
Figure 10.The structure of the studied GCμG.

Figure 10 .
Figure 10.The structure of the studied GCµG.

Figure 11 .
Figure 11.The daily total cost of the GCμG considering different number of stochastic scenarios.

Figure 11 .
Figure 11.The daily total cost of the GCµG considering different number of stochastic scenarios.

Table 1 .
Dispatching approaches in descending order of price.

Table 1 .
Dispatching approaches in descending order of price.

Table 1 .
Dispatching approaches in descending order of price.
1CNY is the official unit of China's currency and 1 USD ≈ 6.7 CNY.

Table 5 .
The TOU electricity prices of Guangzhou city.

Table 6 .
The optimal results calculated using the proposed method and MILP method.

Table 5 .
The TOU electricity prices of Guangzhou city.

Table 6 .
The optimal results calculated using the proposed method and MILP method.