1. Introduction
Every year, an increase in energy consumption has been observed and hence numerous challenges must be tackled such as harmful effects of nonrenewable energy sources (NRES), depletion of energy reserves and controlling energy consumption pattern of consumers etc. As stated in [
1], NRESs are a trivial cause of environment pollution. As a matter of fact, NRESs are the main cause of greenhouse gas emission around the world [
2]. To provide a solution of the abovementioned problem, a strategy is required that employs RESs and manage the electricity demand and supply efficiently. For this purpose, the development of distributed generators (DGs) is required which helps to generate electricity through renewable resources. To establish and maintain a sustainable alliance between DGs and the upstream utility grid, the concept of microgrid came into existence. It integrates DGs and energy storage systems (ESSs) to fulfill the demand of users and ensures the provision of electricity on a small scale. It can operate in two modes: gridconnected and island modes. In a gridconnected mode it sells the surplus energy to main grid and buys from it when its energy generation is less than the demand. In this mode microgrid is always connected to main grid. On the other hand, an island mode is useful mostly in cases when power supply is interrupted due to the detection of any fault in the grid or in regions such as Russia, where 60% of the territories are not connected to the utility due to their geographical positions [
3]. In this case, the connection between microgrid and main grid is terminated.
Optimally scheduling the microgrid resources has become a hot research topic from a couple of years. Devising a strategy for managing energy also puts a great impact to optimize the generation pattern of the microgrid in either of its modes. The authors in [
4] noticed the large integration of RESs in the microgrid due to which the use of ESS dramatically increased. For this purpose, the authors introduced a bat algorithm to develop corrective strategies to perform least cost dispatches. The authors in [
5] employed flower pollination algorithm (FPA) to schedule home appliances to balance the load demand of consumer for demand side management (DSM). Moreover, they put emphasis on the reduction of peaktoaverage ratio (PAR) and electricity cost. Zhang et al. [
6] introduced a method which helps to schedule the microgrid resources. For this purpose, they proposed a hybrid optimization algorithm. Muhammad et al. [
7] introduced an architecture which integrates RESs. A mixmode energy management strategy is introduced in [
8]. It also presents a battery sizing method which helps to operate the microgrid with a minimum operating cost.
The power mix generation has a great impact on the crosscountry relationships. The authors in [
9] presented a set of policy recommendations for the market design of a future European electricity system. They incorporate the dominant share of RESs in line with the stated targets of the European government. Moreover, their analysis covered the interconnection, ESS, distribution generation and network tariffs. In [
10], the authors focused on the effects of electricity market on the dynamics of France and Germany. The impact of German solar and wind power on both market power and prices in the French wholesale market is estimated. The deployment of RESs heavily and directly effects the power as well as the market prices. The integration of RESs has significant impacts on the power price dynamics of the crossborder by reducing the prices and the level of market power. It has been widely accepted that the integration of RESs in the microgrid is a classical solution to the market power problem. However, their deployment is costly and difficult. Since the RESs account for a large share in the spot market. Hence, any change in the spot market affects the market power. In [
11], the authors focused on the impacts of high penetration of RESs in the grid. They have identified the problem that the integration of RESs often indirectly increases the market power fostering congestion problem. Hence, it is not suitable to fully rely on the RESs due to their intermittent nature and energy is exchanged from utility grid in different times of a day. Moreover, the impact of RES on the utility is a different issue which needs to be tackled.
In [
12], authors propose a hybrid algorithm for power generation scheduling of traditional generators, RES, battery storage and electric vehicle (EV). Furthermore, a microgrid connected system is presented in [
13] for controlling distributed energy resources (DERs). They present an improved ABC (IABC) algorithm to perform the required operation. In [
14], a system is presented for microgrids which reduces the net emission and generation cost. However, they did not consider any mechanism to reduce the PAR. In [
15], a robust optimization method is suggested for the optimal flow of microgrid power. In [
16], the authors designed a fuzzy logic–based energy managing system for a gridconnected microgrid of a residential area. Due to high complexity of fuzzy rules, fuzzy logicbased solutions are not capable of incorporating realtime dynamics of an energy management system (EMS). The authors in [
17] modeled and verified a supervisory EMS by formulating the invariants for possible mode change in a microgrid system. Furthermore, the work presented in [
18], introduced a mixed integer linear programming (MILP) model. It helps to schedule loads at the premises of consumer. However, the authors did not consider the integration of RESs which can further help to achieve their desired objectives. In [
19], a home EMS is proposed. However, the operating cost of energy supply resources is calculated. The authors in [
20], presented an energy management controller using three heuristic techniques to minimize the energy consumption and maximize user comfort. Their proposed model also integrates RESs; however, the operating and maintenance cost of RES is calculated. The authors in [
21] proposed an energy management strategy for microgrid using enhanced bee colony optimization technique. They aim at minimizing the operating cost of microgrid. Here, we noticed that the load demand curve has more load on high peak hours as compared to the load on low peak hours. This means that no DSM strategy is implemented at consumers’ end, which needs to be considered. The authors in [
22] presented a microgrid model which integrated photovoltaic (PV) panel, energy storage system (ESS) to manage the load of a building. In our previous work [
23], we have proposed an EMS for a residential area. However, there is a need to further optimize energy consumption and generation patterns.
Moreover, to the best of our knowledge, none of the research works consider to schedule the load at the consumption as well as generation side at the same time which plays an important role in reducing the peak load and electricity generation and consumption costs. Considering the aforementioned limitations, we mainly focus on managing the energy sources of microgrid. As illustrated in
Figure 1, the microgrid helps to locally provide energy to satisfy the load demand of a residential area. The residential area considered in our work consists of ‘n’ number of homes with fixed and shiftable appliances. The energy consumption of each home varies with respect to the factors such as residents’ living habits, electrical appliances and the type of household. In our work, the ESS is being charged when the surplus energy is available and discharged when the DGs cannot generate enough power to satisfy consumers’ demand. We prioritize to fulfill load demand using microgrid, and in case it fails to satisfy the overall load demand, the remaining load demand is satisfied through buying electricity from the main grid. In case, when microgrid produces more energy than the required at a specific time interval, the excessive power is sold back to the main grid.
In this paper, the electricity load at consumers side is optimized using binary bat (BBat) algorithm and binary FPA (BFPA). We have also proposed a novel algorithm and named it as improved BBat (iBBat) algorithm. The BBat algorithm is influenced by the echolocation nature of bats which helps to search the feasible search space. To strengthen the population evolution and the optimization of control parameters, we improve the BBat algorithm by comparing it with BFPA. The BBat has the advantage of quick convergence and easy implementation, but the quick convergence may lead to the lack of accuracy of solutions in high dimension search spaces [
24]. We know that the energy management of residential area and the microgrid is a complex problem with multiple constraints. In the iBBat algorithm, we embed the selfadaptive and repulsive factor [
21] in the flying behavior of the bats which increases the search efficiency and accuracy of solutions in high dimensions. The proposed algorithm helps to efficiently schedule the appliances of a residential area and the DGs of a microgrid in a way to reduce the operating cost. The effectiveness of the proposed algorithm is proved by comparing its performance with BBat [
24] and BFPA [
25]. The contributions of this paper are as follows:
In this paper, we have scheduled the energy consumption and generation using BFPA and BBat algorithms. We have also proposed iBBat algorithm for efficient scheduling of energy consumption at consumers’ side and as well as generation at microgrid side.
The operating cost of energy generators at grid side is reduced along with the energy consumption cost at users’ side. Moreover, PAR of load demand from main grid is also reduced.
The scheduling results of BFPA, BBAT and our proposed iBBAT are compared and depicted in simulation section of this paper.
The rest of the paper is organized as follows.
Section 2 elaborates the mathematical modeling. The system methodology is discussed in
Section 3. In
Section 4, the proposed algorithm is discussed.
Section 5 contains results and discussions.
Section 6 concludes the work.
4. The Binary Bat Algorithm
The heuristic algorithm bat has been influenced by the echolocation nature of the bats. The capability of echolocation enables the bat to find their prey even in the darkness [
24]. Each bat in the search space is encoded with a velocity
vt and location
xt at the
th iteration. The location of the bats can be considered to be a solution vector to an identified problem, where the current best solution is achieved during each iterative of the search process. The original bat algorithm was coined to solve the problems, which are continuous in nature. However, there was not a possible way to directly apply it to binary problems. To make it applicable to binary problems, the authors in [
28] introduce a transfer function (TF) which maps the velocity values to the probability value and in turn, it updates the locations. The TF permits bats to move in a binary search space.
In the BBA, a bat updates its velocity, position and frequency vector in each iteration as follows:
In Equation (
12),
Gbest represents the optimal solution obtained, and
${F}_{i}$ represents the frequency of the
ith bat which is updated in every iteration. To convert the process of search in a continuous search space to a binary search space; a TF is used, which is given below.
In Equation (
15),
${v}_{i}^{k}\left(t\right)$ represents the velocity of the
ith bat at
tth iteration in the
dth dimension, where
${x}_{i}^{k}\left(t\right)$ represents the position of the bat at
tth iteration in the
dth dimension and
${\left({x}_{i}^{k}\left(t\right)\right)}^{1}$ indicates the compliment of
${x}_{i}^{k}\left(t\right)$. The TF permits the bats to move in a binary search space.
The iBBat Algorithm
The classical bat algorithm has been successfully used for many optimization problems such as continuous optimization in engineering designs, scheduling, classification, clustering and data mining. This algorithm is very flexible and easy to implement. It converges very quickly in a very initial stage by switching from exploration to the exploitation stage, and then the convergence rate slows down. It may also lead to lack of accuracy of solutions because it switches very quickly from exploration to the exploitation stage. To avoid the rapid convergence in computations, we introduce the selfadaptive and repulsive factor, which improves the behavior of each bat globally. This factor will help the bats to increase the possibility of accuracy of solutions in high dimensions, which leads to the overall efficiency of the algorithm.
In the iBBat, we introduce a selfadaptive and repulsive factor to improve the global search potential of BBat algorithm. This element helps the bats to fly over the parts of the search space, where they can find profitable information. To enlarge the neglected search space, the authors in [
21] have introduced an interference factor ‘
$\delta $’ in Equation (
17).
Calculating the
$\delta $, initially we consider the value of
p = 0.6. If the value of
p is greater than the rand, a reverse search will be performed as given in Equation (
17), where the value of
p lies in the range [0.1,0.9]. The value of
$\delta $ is recorded, and the value of
p (based on
$\delta $) is adjusted according to the value of the fitness function in each iteration. In iBBat, the flying space of bats is enlarged by including the
$\delta $ in the flying behavior of bats. Hence, Equation (
13) becomes:
The TF is used correspondingly as done in the BBat. The searching procedure of selfadaptive and repulsive factor is given in Algorithm 1. Meanwhile, the proposed algorithm is described in Algorithm 2.
Algorithm 1 Searching procedure of $\delta $ 
 1:
If Min.Fitness$\left({x}_{i}^{k}\right)$ comes from $\delta =1$.  2:
p=p+0.1.  3:
If $p\ge {p}_{max}$ then $p={p}_{max}$ and ip=ip+1.  4:
else ip=0.  5:
If $ip=i{p}_{max}$ then p=0.6 and ip=0.  6:
If Min.Fitness$\left({x}_{i}^{k}\right)$ comes from $\delta =1$.  7:
p=p0.1.  8:
If $p\ge {p}_{max}$ then $p={p}_{min}$ and ip=ip+1.  9:
else ip=0.  10:
If $ip=i{p}_{max}$ then p=0.6 and ip=0.  11:
end

Algorithm 2 The pseudocode of iBBA 
 1:
Initialize the bat population ${x}_{i}$.  2:
Initialize the pulse frequency ${F}_{i}$.  3:
Define the loudness ${A}_{i}$ and pulse rate ${r}_{i}$.  4:
While (t<max. iterations)  5:
Update frequency and velocities.  6:
Update position using Equation ( 18).  7:
Calculate TF using Equation ( 15).  8:
Update position using Equation ( 16).  9:
If (rand)>${r}_{i}$).  10:
Select Gbest.  11:
Change a few dimensions of position vector with a few dimensions of Gbest.  12:
endif  13:
Generate a new solution by flying randomly.  14:
If(rand <${A}_{i}$ & $f\left({x}_{i}\right)<$Gbest) )  15:
Accept the new solution.  16:
Increase ${r}_{i}$ and reduce ${A}_{i}$  17:
end if  18:
Rank the bats and find the current Gbest.  19:
end

5. Results and Discussions
To validate the results of proposed strategy, we have performed simulations in MATLAB. As discussed earlier that in this work, we have considered 10 smart homes. Every home is equipped with shiftable and fixed appliances. Each consumer can alter their energy usage in compliance to the electricity rate at time ‘t’. On the other hand, the microgrid is composed of WTs, a FC, MT, a PV and an ESS as given in
Figure 1. The performance of the proposed strategy has been evaluated in gridconnected and islanded modes of microgrid. Moreover, we have considered a time period of 24 h in this work. The data of PV and WT is acquired from [
14,
29], respectively and their forecasted output power is given in
Table 4 and
Table 5. The price of the open market is taken from [
14].
The load demand of each hour of a residential area has been shown in
Figure 2. We have used the BFPA, BBat and our proposed technique iBBat to optimally schedule the consumption pattern of a user. As shown in
Figure 2, the time duration from 9 a.m.–5 p.m. is considered to be high peak hours because of the high energy consumption. Due to high load demand in these hours, the electricity price is also high. Hence, the high peak hour load is shifted towards the low peak hours, because the electricity cost at these hours is considerably low as compared to the rest of the time slots. Employing this strategy, the power consumption peak is significantly shaved, which consequently results in a uniformly distributed load curve during the day. Moreover, the figure clearly shows that iBBat has reduced the peaks as compared to BFPA and BBat which helps to reduce PAR which the utility favours.
Consequently, the DERs of the microgrid are scheduled by the microgrid scheduler using the techniques that have been used to obtain the optimized consumption patterns of appliances at a home.
Figure 3a shows the results in the gridconnected mode. To minimize the operating cost, we have acquired the ON/OFF states of the DERs through scheduling in the gridconnected mode. In this mode, the microgrid scheduler gives high priority to generate energy from RESs because of their ecofriendly nature and low cost of bids. The microgrid scheduler checks if the consumer’s load demand is less at a particular time ’t’ than the microgrid generated power, then the surplus power is used to charge the ESS considering its constraints given in Equations (
8) and (
9). The charging/discharging states of the ESS are shown in
Figure 3b. In this figure, the charging states of ESS are represented by the positive values, while the negative values represent the discharging states of the ESS to meet the consumers’ demand. Otherwise, the surplus power is sold to the main grid. However, in cases when the consumer demand is more than the power generated by the microgrid, then ESS stored power is used to fulfill the load demand at that specific time slot. Still, if the discharge rate of the ESS is less than the required power, then the remaining load demand is satisfied through buying power from the main grid.
Table 6 shows bids of DERs considered in this research work [
14]. These bids represent the cost at which MT, PV, FC, WTs and ESS generate power on the hourly bases.
The power exchange between the microgrid and the utility is shown in the
Figure 4a–c. Positive stems in these figures illustrate the amount of power bought from the utility grid. The DSM strategy implemented in this research has affected the power exchange. Since the DSM enables consumers to shift their load to low peak hours, less energy is bought from the utility grid in high peak hours. Hence, during low peak hours, the energy bought from the main grid is more as compared to the energy bought from the main grid during high peak hours. Thus, the price of electricity is low in these hours which helps to reduce the overall operating cost. Another observation is that using iBBat the power is bought in only one hour from the utility grid, while in rest of the hours; either the power generated by the DGs is enough or the surplus power is sold back to the utility. At each time slot, the microgrid sells the surplus power at the cost of bids generated by the utility. Hence, the operating cost of the microgrid is further reduced.
When a microgrid operates in the islanded mode, it focuses on both the economic criteria by providing a stable power supply to the residents. As discussed earlier, the microgrid energy is generated in response to the consumers’ demand. Since, the grid does not communicate to the microgrid in this mode, hence, a dedicated energy resource is required to assure power supply. Because of the irregular nature of RES, the MT and FC are more prioritized to provide a reliable power supply. It defines constraints both to work with their maximum capacities to ensure a continuous power supply. The microgrid scheduler acquires the ON/OFF state of DG sources in such a way to minimize the operating cost. The rest of the DERs are turned on by the scheduler depending on the load in that specific time interval.
Figure 5a demonstrates the cumulative behavior of the microgrid resources in the islanded mode to balance the demand and the supply. It is worth mentioning that if the demand of the consumer at any time ’t’ is greater than the supply, then the remaining load is curtailed. To overcome this limitation in this mode, we have enlarged the capacity and charge/discharge rates of the ESS to ensure the power supply, which is enough in the absence of utility grid and to minimize the rate of load shedding.
Figure 6a,b represents the overall operating cost of microgrid in the aforementioned modes. It is clear from the
Figure 6a that BBat has reduced the operating cost of DG sources in the gridconnected mode involving the cost of power exchange between microgrid and utility grid as compared to BFPA, where the iBBat has significantly reduced the operating cost as compared to BFPA and BBat.
Figure 6b illustrates the operating cost of microgrid in the islanded mode. It is clear from the results that iBBat has significantly reduced the operating cost of microgrid as compared to BFPA and BBat. The results given in
Figure 7 represent the PAR of utility. It shows that there is a tradeoff in the PAR and operating cost using BFPA. Because when cost is increased, then PAR is also increased. However, the iBBat has reduced the PAR as compared to the PAR reduced by BFPA and BBat.
6. Conclusions
In this research work, we have proposed an improved swarm intelligent optimization algorithm to enhance the operations of microgrid for improving the economy and the environmental energy efficiency. The proposed algorithm is of great significance to balance consumers’ demands and energy supply. In this regard, we have considered a residential area in this work and scheduled the load demand of each smart home. At each smart home, DSM strategy is implemented which helps to shave the overall peak of power consumption. For this purpose, an optimization technique, iBBat is introduced in this research work. To achieve our objectives, the DERs of a microgrid use the same optimization technique for scheduling. Moreover, the use of power from main grid is also reduced by the integration of the microgrid in our work, which consequently helps to reduce the PAR. Furthermore, the operating cost of microgrid is calculated in both of the considered modes of microgrid. The results show a significant reduction in the operating cost and PAR using iBBat as compared to the operating cost and PAR using BFPA and BBat algorithm. The operating cost in the gridconnected mode has been reduced to 25% and 23% using iBBat as compared to the operating cost generated using BFPA and BBat, respectively. However, in the islanded mode, the operating cost using iBBat has been reduced to 31% and 20% as compared to the operating cost calculated using BFPA and BBat, respectively. In future, we will improve the performance of our system by considering the parameters of user comfort and its effects on the electricity prices. Moreover, we have planned to incorporate the concept of coordination among multiple microgrids to further optimize the grid system and to reduce the greenhouse gas emission.