Optimal sizing and energy scheduling of isolated microgrid considering the battery lifetime degradation

The incessantly growing demand for electricity in today’s world claims an efficient and reliable system of energy supply. Distributed energy resources such as diesel generators, wind energy and solar energy can be combined within a microgrid to provide energy to the consumers in a sustainable manner. In order to ensure more reliable and economical energy supply, battery storage system is integrated within the microgrid. In this article, operating cost of isolated microgrid is reduced by economic scheduling considering the optimal size of the battery. However, deep discharge shortens the lifetime of battery operation. Therefore, the real time battery operation cost is modeled considering the depth of discharge at each time interval. Moreover, the proposed economic scheduling with battery sizing is optimized using firefly algorithm (FA). The efficacy of FA is compared with other metaheuristic techniques in terms of performance measurement indices, which are cost of electricity and loss of power supply probability. The results show that the proposed technique reduces the cost of microgrid and attain optimal size of the battery.


Introduction
In the last few decades, the world is seeing an unprecedented rise in its population with the resultant subsequent excessive power demand, both of which are the main operative factors behind global warming and carbon emissions. Unfortunately, we are still adamantly depending on the usage of fossil fuels which incidentally are still playing the major role in supplying energy for the power generation and transportation system. However, continual and inevitable depletion of fossil fuel resources in the recent years has put a serious pressure to bear on the governments and energy entrepreneurs to be responsible enough to move towards replenishment of energy through RES [1]. Greenhouse gas emission is reduced by replacing fossil fuels with renewable energy and leads to a growth in the industrial sector. However, the intermittent nature of RES is thwarting the stability of the power system in the economic sense of the word, hence, efficiently controlled methods have become the order of the day to overcome the issues PLOS  of voltage disturbances, frequency regulations and network security during the high penetration of the RES to meet the growing demand of the population at large [2]. Table 1 shows all the nomenclature that would be used in this paper.
Microgrids have emerged as a platform to integrate DER, such as diesel generators (DG), wind turbine (WT), microturbine (MT), fuel cell (FC), solar photovoltaic (PV) panels and energy storage system (ESS) within a network to feed into the utility grid in a more orderly and manageable network. Microgrids can be operated in the islanded mode as well as gridconnected mode, depending on the load conditions and electricity market price [3,4], providing the potential to solve the existing power system problems of stability, reliability and demand response.
Because of the limited reach of utility grid, microgrids in islanded mode are more intended for the power balance as compared to the grid-connected mode. Therefore, reliable power sources like synchronous generator and energy storage are the crucial elements to regulate voltage and frequency and improve the stability of the system [5,6]. Over the past few years, ESS has become an essential component of microgrid. The voltage and frequency regulation in an islanded microgrid can be performed by ESS in the absence of synchronous generators. Moreover, the power fluctuations caused by RES can also be reduced by ESS. In addition, ESS is capable of storing the energy during the periods of high-power generation and releasing it when the load exceeds the power generation capacity. ESS with high energy density and longer discharge time are utilized for the applications related to economic energy dispatch and peak shaving. On the other hand, a high power density ESS with a fast response capability is employed for the voltage control and frequency regulation applications [7,8].
Battery energy storage systems are best suited for power system applications due to their technical benefits and ability to provide both the power and the energy density. In order to ensure the reliability, security and economic benefits of the microgrid, ascertaining an optimal size of a BESS is very much essential. Economic scheduling together with an optimal battery size is also significant for rural electrification schemes in small towns where the electrical grid is not available. The operation and the scheduling of the BESS have been addressed by many researchers but the design and estimate of its optimal size to achieve a cost-effective system with minimum power losses is still in progress.
In [9], the energy storage size is determined for the frequency regulation services in an islanded microgrid. The overloading characteristic of BESS is implemented for a short time duration to control frequency, resulting in a quick response of battery to overcome a power mismatch. However, the authors did not consider the impact of lifetime degradation and economic drawbacks by overloading the BESS.
A load shedding scheme for ascertaining an optimal battery size is considered in [10]. The proposed method has made use of a metaheuristic optimization algorithm to control the frequency and minimize the operating cost of the microgrid. A unit commitment approach for the sizing of energy storage system in grid-connected and islanded mode is analyzed in [11]. A typical load profile and renewable energy data have been considered for the BESS sizing to reduce the total cost and increase the economic benefits of the microgrid. The effect of uncertainty of renewable energy on BESS and scheduling of DER are optimized by here and now approach. A multi-objective optimization problem for the optimal location and sizing of BESS is considered in [12] for the purpose of voltage regulation of the microgrid. The authors observed that total losses of the distribution system along with the BESS installation cost and investment cost of the DER are minimized. The voltage profiles of the distribution system were improved and the battery lifetime was extended, thereby saving the replacement cost.
A reliability index known as loss of load expectation has been discussed in [13] that helps to curtail the microgrid operating cost by optimizing the battery size. The economic benefits of the microgrid are justified by providing power from ESS to local loads at a low price during peak periods and controlling excessive power generations. A new approach for an optimal energy management using an Alternating Direction Method of the Multiplier (ADMM) has been proposed in [14]. The authors proposed a centralized controller to avoid congestion in the communication network for the data exchange between the customer and the control center. The ADMM algorithm manages the DER of the microgrid for the optimal energy scheduling. The optimal location and size of energy storage was calculated in [15] to reduce the operation cost and LOLE of microgrid. The bi-objective optimization incorporates the demand response program for peak shaving and economic scheduling of the microgrid. A trade-off between the total cost and LOLE yields the optimal size of BESS. Nguyen in [16] claimed that the vanadium redox battery in microgrid system could be effective in both the islanded and the grid-connected modes. The dynamic programming-based unit commitment method is implemented to find the optimum size of the VRB. Furthermore, the authors consider nonlinear charge/discharge efficiencies as a function of voltage, stack efficiency and temperature. A probabilistic approach for optimal battery sizing was analyzed by using the Monte Carlo simulation in [17]. The time of use tariff and the bidirectional energy transfer with the grid has been taken into consideration for an effective battery sizing. However, the profit of installing BESS decreases with the increase in tariff. A hybrid approach comprising a heuristic and analytical optimization is proposed in [18] to schedule the charge/discharge cycle of BESS in isolated microgrid. The dynamic response is implemented under a real time pricing scheme to maintain a balance between the supply and demand in the microgrid and the BESS. The results report the effective participation of BESS in economic scheduling of isolated microgrid. In [19] the uncertainties of load and renewable power generation are mitigated by scheduling the microgrid such that the BESS provides the spinning reserves service. The proposed discretized step transformation method handles the spinning reserve requirement to obtain a balanced tradeoff between the operation cost and the reliability of the microgrid.
The energy scheduling and the cost minimization method in a real time electricity pricing environment are presented in [20]. The energy flow is coordinated in a model predictive control framework considering the TOU with different renewable energy data for the summer and winter periods. The authors suggested the proposed scheme as a benchmark for the real time electricity pricing to minimize the cost consumption with low and high demand periods. The pricing mechanism under a fixed rate, time of use and a real time pricing are compared in a microgrid environment [21,22]. The results support the real time pricing scheme for the energy selling by distributed generators and energy storage. The information gap decision theory and an interval optimization approach are analyzed to evaluate the risk criteria. In [23], a grey wolf optimization technique has been implemented to determine the optimal BESS size and minimize the microgrid operating cost. The BESS with an initial charge equivalent to its optimal size increases the net profit as compared to the BESS with no charge. A heuristic method incorporating particle swarm optimization (PSO) is used to find the optimal size of the BESS in [24]. The mix-mode energy management strategy is applied to operate the microgrid at the minimum operating cost by integrating three different strategies. Linear programming and MILP methods are used to minimize the cost of the microgrid under these strategies. The genetic algorithm (GA) based method to determine the optimal battery size has been presented in [25]. The proposed method uses the fuzzy expert system to regulate the power flow of the energy storage. A lifetime aging model predicts the lifetime and operating cost of the microgrid.
The lifetime (Ly) of the battery is an essential factor in calculating the annualized cost of BESS, which controls the microgrid operating cost. The lifetime of the battery is affected by two main factors, namely,1) the lifecycle stating the number of charge and discharge cycles a BESS can sustain, and 2) the depth of discharge representing the amount of capacity used by a BESS. In the above literatures, the estimated value of Ly is predicted to calculate the annualized cost of BESS, whereas [25] has used a lifetime prediction model to determine the battery lifetime. However, the calculated lifetime of an optimal battery size is considered to be very short due to deep discharge cycles.
In this paper, a new approach has been presented to schedule the energy resources in the microgrid considering optimal battery size. The addition of energy storage in the microgrid increases capital cost, but also reduces the operating cost of system. Moreover, optimal size of the battery prolongs the lifetime of the storage system and it is significantly affected by the DOD. In this research, to maximize the economic benefit and minimizes the operational cost, microgrid is incorporated with diesel generator, renewable energy and optimal size of energy storage. Therefore, firefly algorithm has been considered to attain the optimal dispatch which minimizes the generation cost. The main goal of the paper is to formulate the battery cost equation for real time analysis considering depth of discharge at each time interval. In addition to that, this research proposes the battery operational cost in term of DOD. Hence optimal DOD, prolongs the life span of BESS. The efficacy of the proposed method has been verified by comparing it with other techniques proposed in the literature. The proposed method manages to attain lower operating cost without the loss of power supply at any interval of time.
The rest of the paper is organized as follows. Section 2 describes the modelling of microgrid and its components. Section 3 presents the power management strategies for the economic scheduling of microgrid and section 4 focuses on the performance measurement indices to evaluate the results. The objective function and the constraints of the system are formulated in section 5. Section 6 describes the methodology of the proposed model to implement the strategies discussed in section 3 with minimal operating cost of microgrid. Section 7 discusses the optimization algorithm whereas simulation results are illustrated in section 8.

Hybrid microgrid system
A hybrid isolated microgrid system contains three subsystems: the power demand, the power generation, and the power distribution subsystem. These subsystems have major impact on the cost of the microgrid system. They are dependent on the climatic conditions and the consumer services. This section presents the power and cost models for the wind, solar, diesel generator and energy storage as the DERs of the power generation subsystem, load profile of the residential area as the demand subsystem and the microgrid itself is configured as the power distribution subsystem. The combination of different RESs improves the system efficiency and reduces the requirements of energy storage as compared to a single RES. The general schematic of the microgrid system containing the three systems is as shown in Fig 1.

Wind turbine model
The power model of a wind turbine (WT) measures the power as a function of the hourly wind speed. The relation between the output power and the speed is given by the relationship below [12]: The cost of power dissipated by wind turbine in a particular day is the product of power dispatched and the initial cost of wind turbine. The capital recovery factor calculates the present value for the 24-hour analysis taking interest rate and projected lifetime into consideration.

Solar PV model
The power measured by solar photovoltaic array is dependent on the solar irradiation and the ambient temperature at each hour. The PV power is given by [26] The cost of power dispatched by solar photovoltaic is dependent on the initial cost and power output defined as

Diesel generator
A diesel generator and energy storage are the secondary power generation sources for the microgrid when the renewable energy cannot fulfill the required electricity demand. The conventional generator serves as a backup energy source and improves the system reliability by smoothing the power generation from the renewable energy source. The high cost of energy storage has captivated the attention of utility providers to utilize diesel generators in the microgrid. There are a total of three generators considered in this study. The cost of the generator in terms of power dispatch is expressed by [27]

Battery energy storage model
The BESS in a microgrid is used to avoid any power mismatch between the demand and generation. The selection of different battery energy storage units, each having its own distinguished characteristics in power and energy, depends on the nature of the power required and the power delivered. Lithium-ion battery is used in this paper as they are currently mainly used for storing wind and solar energy due to its high energy density among other battery technologies, long life cycle and high efficiency [11,28]. The energy storage cost analysis is shown in Fig 2 for different values of power discharge and depth of discharge. The figure depicts that the cost of the energy storage increases when the DOD is high and similarly the cost is increased when the battery discharges more power. The increase in the discharge power results in decreasing the capacity of the energy storage and causes the DOD to be high. However, the continuous discharge of high power from the energy storage at maximum DOD increases the cost of the energy storage to the maximum value. The cost of charging/discharging battery at any time interval as a function of battery power and DOD is formulated in Eq (7) [29,30]. The lifecycle of the lithium-ion battery is represented by an exponential function taken from [31]. The cost function of the battery storage during charge/discharge event is modelled as The state of charge (SOC) represents the status of battery capacity given by where Δt is the time interval taken as 1 hour. The battery charging Z ch batt and discharging Z dch batt efficiency is considered same in this paper and is equal to efficiency of battery.

Power management strategy
The power management strategy of the microgrid has a direct impact on the operational behavior of the system regardless of grid-connected or isolated mode of operation. However, in the isolated mode the power generated from the distributed resources must satisfy the load demand for a secure and reliable operation; otherwise, the system will face load shedding which will increase the cost in term of power losses. The unavailability of DERs at certain times of the day will force the diesel generator and battery storage to operate and dispatch optimal power. Moreover, an excess power generation by renewable resources necessitates the charging of the battery. The extra energy after charging is dissipated into dump load to avoid overcharging of batteries. Thus, an efficient power management strategy is required to dispatch the power at the lowest cost to reliably serve the load considering the technical constraints of the microgrid. The power strategy for economic scheduling in this paper has been summarized into the following scenarios: Scenario 1: Renewable energy sources are capable to provide sufficient energy to meet the load demand and the battery is charged by the excess energy.
Scenario 2: This scenario is identical to scenario 1 with the exception that the battery is fully charged and the extra energy generated by renewable sources is dissipated as a dump load.
Scenario 3: Renewable energy resources cannot satisfy the required load of the system. The algorithm will decide to run the diesel generators or discharge the battery depending on the required load and the cost accumulated in two distributed sources. Scenario 4: The renewable sources energy generation is insufficient to satisfy the required load and depth of discharge of battery storage is high, with the result that the generator will dispatch the remaining power and also to charge the battery to reduce the depth of discharge.

Cost of electricity
The cost of electricity is calculated as an indicator of the economic profitability of hybrid microgrid. The electricity cost is the ratio of the sum of the costs associated with solar photovoltaic (C PV ), wind turbine (C WT ), diesel generators (C d.gen ) and the energy storage (C BATT ) to the total load of the day. The electricity cost is measured between all the power generation resources and load for the 24-hour analysis.

Reliability analysis
The reliability of the microgrid is measured by the statistical parameter loss of power supply probability. The reliability parameter signifies the probability over the time horizon when the generation fails to satisfy the demand. This failure can be either due to the improper designing of the distributed energy resources, immediate drop in renewable energy or increase in power demand. LPSP can be calculated by either using time series data or by determining the energy accumulative effect over the total load. The latter technique has been used in this paper, as shown by the expression ðP L À P PV;out À P w;h À P batt;dch À P d:gen Þ

Problem formulation
The above-mentioned power management strategy is implemented to obtain an optimal battery size and daily economic scheduling of microgrid. The capital cost of battery constitutes a major factor in calculating the battery size. The optimal BESS sizing is obtained by minimizing the daily scheduling cost of the microgrid and BESS total cost per day. Hence, the objective function of the microgrid is the total operating cost given by the expression The scheduling cost for the day is the sum of the cost of three diesel generators dispatching power to fulfil the load demand and the cost of charging/discharging the battery storage. In this study, N is taken as three while the time period T is formulated as 24 hours. The TCPD of battery storage is the function of battery capital cost and yearly maintenance cost accounted for the lifetime of battery. The optimal battery size will minimize the total cost of microgrid.

Constraints
The energy management operation of the microgrid has been optimized by meeting the following constraints: 5.1.1 ESS constraints. The battery charging and discharging energy is expressed in Eq (16) [11]. The battery discharges when P batt is positive whereas negative P batt indicates charging status of BESS. The associated constraint (17) limits the battery power to minimum and maximum value. The charging and discharging of battery depends on the status of the battery power itself, wherein the battery power will be positive in discharging mode and negative in the charging mode. The binary variable μ batt,st states the operating status of the battery. The battery discharges only when μ batt,st is 1 and charges when μ batt,st is 0 avoiding the simultaneous charge and discharge event at any interval. The maximum amount of power charged and discharged by the battery storage during the time t is shown by P max batt;ch and P max batt;dch respectively. The battery capacity at each interval is within the minimum E min batt and maximum E max batt level. The maximum and minimum energy storage capacity in this paper is set as 90% and 15% respectively.

Power balance constraint.
The primary constraint in the power system is the balance of demand and supply. The microgrid must balance the power flow each time step expressed by Eq (22) P PV;out ðtÞ þ P w;h ðtÞ þ P batt ðtÞ þ P d:gen ðtÞ À P L ðtÞ ¼ 0 ð22Þ

Proposed method
The proposed method calculates the optimal battery size and performs economic scheduling of the distributed generators as per load demand at each hour. The economic scheduling is based on the power management strategies discussed above and is similar to the conventional method when there is an excess of energy through the renewable sources than that required by loads such as in scenarios 1 and 2 of the power management strategies. However, when the load power is greater than the renewable energy generation, the proposed algorithm will dispatch the power from diesel generators or the energy storage. The decision is based on the depth of discharge of the energy storage, which affects the operational cost of storage. The algorithm reads the DOD value at the start of the interval and then transforms the cost function given in Eq (7) from 3-dimensional to 2-dimensional plot. The proposed optimization algorithm dispatches the optimal power from the three diesel generators and the energy storage, depending on the cost equations of the respective distributed power resources and the load demand at the specific hour. In addition, the proposed method also directs the diesel generators to charge the energy storage when the cost of the BESS per unit of energy is higher than the generator cost. At this stage, the battery DOD is high which may account for the power supply loss during the hours when the battery is required to dispatch power. The battery SOC is computed at the end of each hour after the algorithm takes the decision to charge or discharge the battery. The battery optimal size is calculated for the defined strategies so that the cost is minimum for the scheduling of the power resources which will reduce the overall cost of the microgrid. The battery optimal size is selected from a range such that the lower value E l;t corresponds to the battery size in which there is no mismatch between the generation and load whereas the upper value E u;t sustains the maximum charge at each interval. The battery size range in this paper is taken from 100kWh to 250 kWh. The flowchart of the proposed method is shown in Fig 3.

Firefly algorithm
The firefly algorithm (FA) analyzes the social behavior of flies and is similar to other meta-heuristic techniques. The algorithm was originally developed by Yang [32] based on three main ideas: 1. The fireflies attract their mating partners.

The bright firefly gets attracted towards brighter fireflies.
3. If the firefly cannot find brighter fireflies, then it will move randomly in the search space.
Like other optimization techniques such as artificial bee colony (ABC), PSO and harmony search algorithm (HSA), which are based on the population of search space, FA is also a population-based optimization algorithm. However, FA is distinguished from the other optimization techniques by adjusting the parameters, which have low dependency on the algorithm and appropriately identifying the search space. The above mentioned three ideas of firefly algorithm are explained in the mathematical form below:

Separation between fireflies
The distance between two mating fireflies in the search space is calculated as vector operation performed in Cartesian framework between i th and j th firefly given by the expression: where r is the distance between two fireflies, S is the dimension of control vector, Y i,D /Y j,D are the D th dimensions of Y i /Y j fireflies respectively.

Attraction between firefly
The attraction of the fireflies decreases when the two mating fireflies moves in opposite direction and the separation between them increases. The attraction of the flies can be represented by the following expression: where β(r) and β 0 represents the attractiveness when the fireflies are at the distance r and 0. γ is the coefficient of light absorbed by firefly and m is the number of fireflies taken as 2.

Movement of the fireflies
The fireflies move towards brighter fireflies. The movement between the two fireflies, j th firefly (low intensity) towards the i th firefly (high intensity) is given by mathematical expression: The first term of the Eq (25) shows the present position of j th firefly. The second term represents intensity of brightness by which the j th firefly is attracted towards i th firefly. However, the last term v j represents the movement of j th firefly in the entire search space when it cannot find fireflies with more intensity. The randomization parameter δ is a constant value in the range of 0-0.5. The pseudo code of the firefly algorithm is shown in Fig 4.

Results and discussion
A typical low voltage microgrid with three diesel generators and a lithium-ion battery is analyzed in this study to illustrate the performance of the proposed energy management strategies. The microgrid consists of 68 kW photovoltaic and 37 kW wind turbine system. The data for the diesel generators are taken from [33] and is shown in Table 2. The battery capital cost, maintenance cost, interest rate and lifetime had been taken from [34]. The parameters for the wind turbine, solar photovoltaic, energy storage and optimization algorithm are represented in Tables 3-6 respectively. The proposed method is formulated in MATLAB (R2016b) and run on the personal computer 2.6 GHz core i5 processor with 6 GB RAM. The computational time involved in the simulation is about 3 min 15 sec. The generation subsystem is designed to meet the peak load. However, intermittency of RESs and consumers' behaviors may affect the electricity cost and system reliability. A typical load profile of small residential area with the peak load of 163 kW has been taken in this study. The microgrid load profile and renewable energy generation graphs are shown in Fig 5. The load demand at most of the instances are higher than the combined wind and solar power generation. Thus, the generator and battery storage will be operated at these instances. However, there are certain instances when the renewable power generation is slightly higher than the load demand. Hence, the surplus power will charge the energy storage and the generators remains in the rest state during these time intervals. The diesel generator will charge the battery storage when the cost of battery storage becomes higher than the diesel generator cost. This increase in BESS cost is due to the continuous discharge of battery, which raises its DOD value. The battery must also be charged to avoid any load shedding or power failure in the next hours due to uncertain nature of RESs. This will increase the lifetime of the battery as the battery will operate at lower DOD values. The battery storage used in the microgrid operation is assumed to be initially charged at 75% SOC. The proposed strategy is implemented based on the three cases below and the operating cost is computed in each case.

Case A: System is running without the battery storage
The microgrid is operated without the energy storage. Thus, there will be no cost for the TCPD and the objective function is restricted to the daily economic scheduling of the microgrid. The RESs and diesel generators have to satisfy the load demand at all instances. However, there are some instances where the renewable and diesel generators cannot fulfil the required load, thus, there will be power mismatch between the generation and demand. This power mismatch will imbalance the system and will result in a power loss due to load shedding. The load shedding accounts for the penalty to be imposed increasing the scheduling cost of the microgrid. However, when the RES power is higher than the loads, the surplus power from the renewable energy sources will be dissipated as a dump load. Fig 6 shows the generation curve of the distributed sources and the load profile.

Case B: Battery size of 100 kWh is added to system
The renewable sources and diesel generator cannot meet the load demand at all instances, hence, the battery storage must be installed in the microgrid system. In this case, a battery size of 100 kWh is added to the system. The battery size is selected such that there is no mismatch between the generation and the load at any time of the day. The battery is discharged when the cost of battery is lower than generator cost and charged when the battery cost becomes higher. The scheduling cost of the microgrid for the day in this case is calculated as $281.37 whereas the battery TCPD is $ 70.90. The cost of electricity of a day for this load profile is 18.44 (cents/ kWh). Fig 7 shows the battery DOD for this case and it can be seen from the figure that during the certain instance, the DOD becomes higher than 70%, which will greatly impact the cost of energy storage during charge/discharge. Also, the battery charge at the end of the day is low which may impact the operation of the next day. The operation of all the distributed resources in the microgrid with battery size of 100 kWh is represented in Fig 8. In this figure, diesel is the accumulative sum of all the three diesel generators power dispatch.

Case C: Optimal battery size is added to the system
The optimal battery size for the microgrid operation is determined to produce a cost-effective system. The proposed algorithm computes the optimal battery size to minimize the OC of microgrid. The proposed method calculates the battery size to be 145.5 kWh. The operating cost for the optimal size is found to be $ 325.62. To validate the result of the proposed method, the microgrid OC has been computed for the battery size within the range of 100kWh -250kWh with a step size of 15kWh, considering all the constraints of the distributed energy resources and the battery. Fig 9 shows the scheduling cost, TCPD and the overall OC for the different battery sizes. The optimum battery capacity for this system is recorded to be  145kWh, similar to that by the proposed method. The results show that the scheduling cost is high for smaller battery sizes, and as the size is increased the cost slightly reduces. This trend is followed until the battery size reaches up to 145kWh after which the scheduling cost increases again. The TCPD of battery is a linear curve which increases with the size of the battery. The OC for the microgrid shows a very small change in the cost until the battery size reaches 145kWh and gradually increases thereafter.
The battery DOD for the entire time period is shown in Fig 10. It can be seen from the figure that during the initial hours, the battery is discharging with an increasing DOD value. At 06:00 the battery DOD has raised to 38% at which level it upsurges the battery cost while the generator discharges more power and simultaneously charges the battery. After 09:00, the generator alone cannot fulfil the load demand, hence, the battery has to discharge in these instances to avoid load shedding. The DOD value at these instances increases and the battery discharges irrespective of the high cost. As soon as the high load period ends, the generator charges the battery again, to ensure sufficient charge during the critical hours. The critical hours are considered as those hours when the renewable energy and diesel generator working together cannot meet the load demand; despite the high cost of the battery storage, it discharges power to fulfil the load demand. Thus, the battery is never depleted completely and avoids deep discharges which prolongs the battery lifetime.
The battery charging and discharging power analysis is shown in Fig 11. The battery discharging power is represented by a positive value whereas the negative value shows the charging process. The figure shows that most of the time the battery is discharging. The discharged power varies during these instants. The maximum discharge power in a one-time sequence is set to 25kW. This is to avoid complete discharge of the battery storage in one interval so that the battery can be utilized during critical hours. The renewable power generation is high during the hours 00:00-02:00 and 15:00-17:00 and the excess energy is stored in the battery.
The generation from all the distributed resources and the load demand are plotted in Fig  12. Diesel generator 1 has the lowest cost among the other diesel generators and it also dispatches maximum power. Generator 3 is given the least priority among the three generators due to its high cost. The generation and load are balanced at all the instances which restricts any penalty to be imposed thus reducing the overall operating cost.
The results for the above cases are tabulated in Table 7. The renewable power generation in all the cases is identical, and the economic dispatch is performed for the power difference between the load and the renewable energy. The negative values in the BESS shows the charging schedule while the positive values represent the discharging schedule. Generator 1 dispatches more power due to it being the cheapest among the three generators, whereas generator 3 dispatches minimal power. The battery DOD curves for the different battery sizes are shown in Fig 13. The figure shows that DOD values for the optimal battery size of 145 kWh is lowest at most of the instances as compared to other battery sizes. The lifecycle and lifespan of the different battery sizes are tabulated in Table 8 by Battery sizing and economic scheduling of microgrid taking the average of the DOD. The optimal battery capacity results in longer lifetime in comparison to other battery capacities and the conventional method [26]. Thus, the optimal size and the economic scheduling may prolong the battery lifetime and reduce the microgrid cost.

Comparison of proposed technique with the conventional technique
The effectiveness of the proposed method is verified by comparing it with other conventional methods [26,35] in which the battery storage discharges when the renewable resources fail to provide sufficient energy to meet the load. When the battery reaches minimum energy level, the diesel generator is turned on to charge the battery storage. This method reduces the lifetime of battery storage by continuously discharging to the minimum level. The authors in [26] have used PSO to get the optimal power dispatch. The comparison is done by implementing the conventional method using the above-mentioned parameters, and the results are shown in Table 9. It is apparent from the table that the proposed method reduces the operating cost by 50% as compared to the conventional method. The battery depth of discharge status for the conventional method is shown in Fig 14 which depicts that the DOD is higher at most of the instances over 24 hours due to complete power discharge from the energy storage. Thus, the operating cost of the microgrid by using the conventional method is high as compared to the proposed method. The overall power generations and load for all the time intervals are plotted in Fig 15.  Battery sizing and economic scheduling of microgrid

Comparison of proposed optimization algorithm with other algorithms
The robustness of the FA is analyzed by implementing ABC, HSA and PSO for the proposed method and the results are reported in Table 10. The table shows that FA has the minimum operating cost with 0% LPSP. However, PSO and HSA are not capable to meet the load demand at all the instances resulting in the load shedding and has a higher LPSP ratio. The battery discharging cost is the ratio of the accumulated battery cost at all the instances in which the BESS is discharged to the sum of the power discharged by the BESS. The battery discharging cost of FA is the minimum of all the other algorithms and depicts that the BESS does not discharge more power at high DOD values thus reducing the scheduling cost of the microgrid. The battery DOD has been compared for all the algorithms and the results are shown in Fig 16. The results illustrate that FA has been capable of limiting the battery DOD to a low value to minimize the battery operational cost. The scheduling cost for the hourly analysis with the battery size of 145kWh had been compared with the above-mentioned algorithms as in Fig 17. The figure clearly depicts that the cost at each hour by FA is comparatively lower than other algorithms which reduces the overall operating cost of the microgrid.

Conclusion
As more energy supplies are predicted to utilize renewable sources, the economic and battery sizing aspects of the energy storage in the isolated microgrid has to be taken into consideration to ensure a reliable service. The present study has solved the economic scheduling problem between the diesel generators and the battery storage considering real time battery degradation cost. One of the strengths of the proposed method is to charge the battery when the DOD value is high so that the battery is not depleted during critical hours. Firefly optimization algorithm was implemented to solve the economic dispatch and the battery sizing problem. The simulation results reveal that the microgrid faces the load shedding without the battery storage resulting in high operating cost and instability. Furthermore, a large BESS size does not minimize the operating cost, but there exists an optimal point, which should be considered when designing a microgrid system. The lifespan of the battery is also extended when optimal size is selected for economic scheduling saving cost of  Battery sizing and economic scheduling of microgrid replacing BESS. The proposed method has been compared with other existing methods and 50% reduction in operating cost has been recorded. Thus, the obtained results show that ignoring the depth of discharge and lifetime of the BESS in an economic scheduling will inflate the operating cost of the microgrid. The energy scheduling approach presented will help the independent power plant operators to perform the rural electrification efficiently and prolong the battery lifetime.