Two-Stage Energy Management of Multi-Smart Homes With Distributed Generation and Storage

This study presents a new two-stage hybrid optimization algorithm for scheduling the power consumption of households that have distributed energy generation and storage. In the first stage, non-identical home energy management systems (HEMSs) are modeled. HEMS may contain distributed generation systems (DGS) such as PV and wind turbines, distributed storage systems (DSS) such as electric vehicle (EV), and batteries. HEMS organizes the controllable appliances considering user preferences, amount of energy generated/stored and electricity price. A group of optimum consumption schedules for each HEMS is calculated by a Genetic Algorithm (GA). In the second stage, a neighborhood energy management system (NEMS) is established based on Bayesian Game (BG). In this game, HEMSs are players and their pre-determined optimal schedules are their actions. NEMS regulates the total power fluctuations by allowing the energy transfer among households. In the proposed algorithm, HEMS decreases the electricity cost of the users, while NEMS flats the load curve of the neighborhood to prevent overloading of the distribution transformer. The proposed HEMS and NEMS models are implemented from scratch. A survey of 250 participants was conducted to determine user habits. The results of the survey and the proposed system were compared. In conclusion, the proposed hybrid energy management system saves power by up to 25% and decreases cost by 8.7% on average.


Motivation and Background
With the advancement of technology, increase in consumer comfort level and widespread use of electric vehicles cause more electricity consuming products to be introduced into our daily lives. As electrical loads in the existing power grid increase, the demand and supply gaps widen. Increasing the electrical generation capacity alone does not reduce this gap due to power loss in inadequate transmission and distribution infrastructures. Smart grids which integrated with distributed production and storage systems, information technologies and advanced control algorithms, can overcome this problem [1]. Energy efficiency in smart grids is achieved by managing demand side, distributed generation and storage systems [2][3][4]. In this context, Demand Response (DR) programs have been encouraged to enable customers to utilize the existing energy more efficiently and reduce the cost. DR strategy provides adjusting the electricity usage pattern of users by interacting between the power supply company and customers [5]. To flatten demand fluctuations, the price-based DR is preferred and the incentive-based DR is opted to reduce peak demand and encourage consumers to lower their electricity bills [6][7][8].
Today, a noteworthy amount of the total energy generated is consumed in household appliances. It is possible to supply these demands by utilizing existing energy efficiently. In this context, HEMS has been developed to control household appliances, manage distributed production and storage systems, monitor energy usage, and reduce electricity costs [9]. In Figure 1, energy management system coordinates power and data transfer among smart homes in the neighborhood. HEMS receives information by communicating with devices and utilities and tries to mitigate electric consumption by scheduling the devices [10]. The scheduling problem of HEMS is solved by effective and intelligent algorithms [11,12]. EVs inject power to the grid during discharge, while drawing energy from the grid during charging. Thanks to their large capacity, they improve flexibility of power system [13][14][15]. The bidirectional feature of EV charger offers flexibility to HEMS to make more functional choices [16,17]. Surplus energy generated from renewable sources in smart homes is stored in batteries or sold to the power grid [5]. The dynamic pricing structure regulates exchanging energy between users and the power grid. Thus, the consumers may get profit by selling their surplus energy or by purchasing energy when needed. Other than the renewable energy sources, both heat and power needs can be met by using m-CHP in consumption places. M-CHP can be utilized alone or with hybrid enery storage systems [18]. However, in this study, m-CHP was not preferred because fossil-fueled resources were not expensive and environmentally friendly. Furthermore, when energy was supplied within the neighborhood, transmission and distribution losses reduce in the power grid. Observing the demands and supplies of each smart home, NEMS coordinates all assets in the distribution system from a center [19,20].

Related Works
Although HEMS studies started in the 1990s, it has been a popular topic since 2010. A large number of HEMS models has been proposed. Tsui and Chan [21] improved a versatile convex programmatic DR strategy for the optimal operation of appliances with a variable price signal. Pradhan et al. [22] developed an effective DR strategy for end user energy management considering user comfort level and dynamic pricing signals. Lee et al. [23] and Yang et al. [24] suggested a comprehensive price-based DR strategy to optimally regulate supply and demand via centralized or decentralized models. This DR focuses to determine the ideal schedule of generation, storage and consumption appliances. Hemmati and Saboori [25] proposed a HEMS model that includes the most appropriate solar, wind and battery systems to address energy fluctuations. Patel and Khosla [26] presented a model that reduces the electricity bills of users in DR programs by mitigating electricity energy usage in peak periods and shifting the peak load time to an off-peak time. Kuzlu et al. [27] explained a HEMS strategy that limits the peak power DR for smart homes including both electrical devices and EVs. Wu et al. [14] proposed a price-based DR strategy that reduces energy costs and shaves the peak demands by incorporating the EV charger in G2V, V2G and V2H modes. A real-time game algorithm was proposed to minimize customer's electricity cost by alleviating peak demand [28]. Researchers also benefited from distributed generation and storage to transfer energy from one time span to another period, to schedule appliances. This allows to mitigate the peak-demand and to flatten the load curve as well. Hilshey et al. [29] presented a smart charging algorithm to reduce overloading of a transformer by analyzing distribution transformers during EV charging. Guo et al. [30] proposed a decentralized Lyapunov-based cost minimization method to coordinate the activities of smart homes in a neighborhood, to minimize electricity cost and to satisfy the transformer capacity limits. Erdinc et al. [31] tried to prevent the overloading of the distribution transformer by evaluating both the pricing and the peak power limiting DR. Gong et al. [32] studied innovative solutions for the practical utilization of the distribution system and the charging effects of EV on the distribution transformer.
Cabras et al. [33] presented a smart HEMS that allows automatic control the devices in smart homes whitin the same neighborhood. In order to save energy in the proposed model, not only the distribution systems but also renewable resources have been evaluated in the device's task plan. Celik et al. [34] proposed an energy management algorithm based on incentive and price. In this algorithm, RES and ESS for households in a small-scale neighborhoods are considered. The aim of the proposed coordination method is to reduce the electricity costs of households by increasing the usage of renewable energy in the neighborhood and enabling electricity trade among smart homes. Nizami et al. [35] introduced an integrated approach to the HEMS for a residential area that reduces the demand peaks in the neighborhood and electricity bill of participating users. Joo and Choi [36] proposed a two-level-distributed HEMS algorithm. In the first stage, appliances are planned by taking into account the comfort level of consumers. In the second, for optimizing the electricity cost of a neighborhood, the energy trade between ESS and neighboring households is regulated.
There are many optimization approaches in order to manage HEMS and NEMS. One of them is Mixed-integer nonlinear programming. It schedules variable residential loads and renewable energy sources, optimizes energy consumption and minimizes the cost in buildings Erdinc et al. [31]. The game theory method was introduced by Mohsenian-Rad et al. [37] to specify an appropriate consumption schedule for users in a neighborhood. The PSO technique is utilized to extract optimum runtime for devices, taking into account user preferences, weather conditions and device priorities Wang et al. [38]. Ahmed et al. [39], introduced a new binary backtracking search algorithm based on real-time appliance scheduling. It helps to limit the user's peak demand and to achieve energy savings according to the end user's comfort constraints and priority.

Contributions
This paper presents innovative solutions for a single household as well as all homes in a neighborhood. In this study, both the energy cost of a household and the total power consumption in a neighborhood are equally important. With a decentralized energy consumption scheduling algorithm for each household, a certain number of optimizations is applied so that the household's total cost becomes minimal. NEMS apply these optimization results in each household to a Bayesian game and which optimization result should be used for each household. In summary, our paper makes the following contributions: 1.
The proposed model has two-stage hybrid energy management system.

2.
The proposed approach aims to reduce the cost of energy in terms of households. Also, it supports the distribution system by shaving the total demand peak in all periods in the neighborhood.

3.
A new indicator index has been suggested to reduce total demand peaks in the neighborhood by coordinating all assets.

4.
While HEMS uses the GA optimization method to schedule apliances optimally, NEMS coordinates smart houses in the neighborhood by establishing a Bayesian Game.

Organization
The rest of the paper is organized as follows: the system model is presented in Section 2. The developed algorithms are expressed in Section 3. Section 4 presents tests and simulation results. Finally, the conclusions are discussed in Section 5.

Distributed Generation Systems (DGS)
Most of the energy generated from central power plants is generated from fossil fuels such as oil, coal and natural gas. Conventional energy resources are limited, expensive and when they are consumed, carbon emissions occur. In addition, transmission and distribution losses occur when the energy generated in these plants is transferred to consumers. To increase the use of renewable resources for the reasons mentioned above, governments offer incentives to energy producers and consumers. In this context, producers set up solar and wind farms to sell energy, while consumers build solar panels and wind turbines on the roofs of their homes to supply some or all of their energy needs.
The total energy generated from household resources is given in (1).
The energy generated from household resources is consumed momentarily or the surplus energy is stored to use when it is needed in standalone systems. The usage, storage and sales equality of the energy produced in the household are given in (2). On the other hand, in grid-connected systems, it is given in (3) that excessive energy is sold to the power grid or to other housesholds.

Distributed Storage Systems (DSS)
ESS and EVs are used for energy storage in households. In periods of low electricity prices, energy generated from DGS or purchased from the grid is stored in the ESS. Then, stored energy is utilized instead of buying electricity when it is expensive. EVs are generally charged at times when the electricity price is cheap and demand is low. If the electricity price is expensive and the demand is high during the periods when EVs are at smart homes, the energy stored in their battery is transferred to households. The operational constraints of the DSS components are described in detail in (4)-(6) below.
Although the battery groups are charged from the grid or the DGS, it is particularly desirable that ESS be charged from DGS. Since no energy will be generated from PV during periods when an EV is at home, it is inevitable that an EV is charged from the wind turbine or the grid.
The energy stored by the battery groups before charging and discharging must be known. Because the maximum and minimum capacity values that show the safe working area of each battery are defined, they are allowed to work between these values. The stored energy in the battery is expressed by Equations (7)- (10).
Energy storage is expensive. For this reason, the battery capacity should be chosen in the best way in HEMS. Instead of buying a high-capacity battery, HEMS can provide optimum performance with a battery of normal capacity.

Electrical Appliances
Electric appliances used at the household for daily needs of the consumers are called residential loads. These loads are: non-deferred and non-interruptible loads, deferrable and non-interruptible loads, deferrable and interruptible loads, and temperature-controlled loads. The operation of non-deferrable and non-interruptible loads cannot be shifted to another time and their operations cannot be interrupted until they have completed their task. The operation of deferrable and non-interruptible loads can be shifted over time, but after it has started operation, they have to complete their tasks with non-interruption. Deferred and interruptible loads can be started or stopped to operation when requested according to the consumer preference. Temperature controlled loads such as water heaters and air conditioners operate depending on ambient temperature and consumer comfort level. When, how long, and in which mode the devices are used depend on consumer preferences. The operating constraints of the device are expressed in (11)- (13).
The operation times of appliancec are defined in advance by the user. The power consumption of devices which have different operation phases or are controlled thermostatically vary throughout the run time. An appliance can operate in only one of its phases.

Objective Function
The purpose of this study is to develop an energy management strategy that diminish the total cost of electricity, flatten the load curve in a smart home and prevent overloading of the distribution transformer in the neighborhood of smart homes. To solve such a problem, a two-stage method is proposed. In the first stage, the operation times of the appliances in each smart home are scheduled by considering the electricity price, produced and stored energy, and consumer preferences. In the next stage, power consumption in all periods has been minimized, taking into account the possible electricity consumption schedules of smart homes. Both objective functions cover a period of one day, not an invoice period. The cost of electricity and power consumption are calculated according to the duration of use. Objective functions for smart homes and neighborhoods have been examined in detail.

Smart HEMS Strategy for Each Household
Smart homes consist of equipment such as a roof type solar panel, a roof type wind turbine, an EV and electrical appliances. The nominal power parameters of these equipments in each smart home can change according to consumer preferences. The day-ahead price signal is used for cost planning in the presented model. Of course, this is not the actual price of the next day, but it provides an indication about the expected prices. The day-ahead hourly-price signal for 24 h is received by smart homes with the smart-meter and is used by the optimization algotithm.
In order to construct objective functions, the expression of the utilized and total power for a smart home h in unit period t are given in (14) and (15), respectively. The Formula (16) depicts the average power consumption for a smart home h. These constaints are auxiliary equations to simplify the flat objective Function (17). The Equation (18) is formed for cost optimization.

Smart NEMS Strategy for a Neighborhood
HEMS is responsible for making optimal control to minimize the energy cost of each smart home. Each HEMS presents a certain number of operation scheduling to consumer for this purpose. NEMS communicates with each HEMS to get their schedules and tries to minimize the power consumption of all smart homes at all t periods.
Time-varying day-ahead prices are sorted in descending order and the average of power consumptions is calculated at the same price periods. By starting from the average consumption of the greatest price period, the average of each price period is proportioned to the average of the next price period, and the sum of these ratios is defined as a new indicator. The power consumption difference between the price periods is reduced by minimizing defined indicator. In other words, the price transitions has softened to flatten the load curve of the smart home. NEMS are expressed in (19)- (21).

Genetic Algorithm for HEMS
GA searches an optimal solution in the solution space for the objective function according to the defined constraints. In our project, we divided a day into 5 min intervals. Thus, each appliance is represented by 288 (24 × 12) bases. One individual is encoded m × 288 bases where m is the number of appliances in the home. The length of the chromosome is directly related to the number of appliances in the home. Once the population is created, the objective function is evaluated in terms of fitness. The fitness includes two objective functions that minimize the cost of the smart home and flatten the load curve. To derive a single objective function, balance coefficients are determined for cost and flatten functions. In (23), the fitness value is calculated by using the coefficients (k 1 = 0.1, k 2 = 2.7) keeping the cost function dominant.
We set the size of the population to 1000. For each generation, 10% of the indiviuals are selected based on the fitness function. In order to populate the next generation, we applied 0.5% mutation and 5% crossover operations. Crossover refers to exchange controllable devices among the individuals. On the other hand, mutation helps to move the operation time of a single appliance in the selected cromosome. The GA method requires approximately 1 min to calculate a feasible solution. For each smart home, GA module computed five possible solutions. HEMS manages the devices in a smart home in a 24-hour period. The implemented genetic algorithm for the recommended HEMS models is given in Algorithm 1. for i ← 1..g do 5: while op < Operation do 6: for randomness in Population i−1 do 7: select x,y ∈ Population i−1

10:
Population i ← Population i + mutation(z) 11: e new ← COMPUTE(22, Population i ) 12: if e new < e best then 13: e best ← e new 14: return e best

Bayesian Game Theory for NEMS
All smart homes in the neighborhood that participated in NEMS are players in the established Bayesian game.
There are h players (smart homes) and each player has five actions (optimal solutions) in the Bayesian game. Since the submodel solutions aim to minimize the gain, the general (24) and special (20) target functions are added with a negative coefficient, as shown in Equation (25).
In order to reach the solution of a Bayesian game model, the Bayesian Nash equilibrium needs to be extracted. This equilibrium is provided by determining an optimal strategy s * (s * 1 , s * 2 , . . . , s * h ) by incorporating the gain function expressed in (26). The belief function p is the core of the bayesian game theory. After computing the belief functions, the equilibrium equations are reevaluated.
The players do not communicate with each other and they prefer any strategy independently. The NEMS knows the actions of each smart home and its gains. Thus, NEMS updates the beliefs of the other players according to the possible actions of each player. The Bayesian game Algorithm 2 is developed and implemented for our NEMS model.

Input Data
In our Bayesian game, there are five players, h = 5 and the time interval is 5 min as mentioned earlier. According to the preferences of consumers, nominal power and operation period for appliances in all smart homes are given in Table 1. Since the operation periods of HVACs vary depending on the ambient temperature, their operation periods are not indicated. Every home may not contain all appliances and each device may not be utilized daily.
Washing machine and dishwasher characterized as controllable loads, and they have different stages. As expressed in Table 2 there are eight and four stages for the a washing machine and the dishwasher, respectively.

Wat Was Rin Squ Wat Was Rin Squ Wat Was Rin Dry
Home-1 Period (m) 1. The installed powers of the roof type PV and wind turbine in smart homes are given in Table 3. Home-1,2,4 and 5 include PVs, Home-3 and 4 include wind turbine and only Home-3 includes both of these production systems. The EV and ESS parameters of the houses are given in Table 4. Since residents have different EV types, the battery capacity and the charger characteristics vary. For a real scenario, the arrival and departure times of EVs were set arbitrarily. On the other hand, the ESS parameters are selected according to the installed power of the distributed generation. Due to the utilization of the electricity price in the objective function directly, the price is one of the most important parameters for the optimization model. The day-ahead price has a dynamic structure determined daily by the energy market. We incorporated this parameter in both HEMS and NEMS optimization phases. In this study, buying and selling prices in all periods are considered equal. The price signal is shown in Figure 2.

Simulation Results
In this study, a two-stage simulation was performed. The HEMSs are designed in the first phase. For each household, five possible outcomes were produced by GA. The possible solutions calculated separately for both the load curve (see Equation (16)) and the cost (see Equation (17)). These solutions are given in Table 5 clearly. When cost-based objective functions are examined, 1st program for home-1, 5th program for home-2, 2nd program for home-3, 3rd program for home-4, and 1st program for home-5 yields optimal energy consumption. On the other hand, when load curve flattening objective is considered, the programs 5, 4, 1, 4 and 4 provide optimal power consumption for homes-1,2,3,4 and 5 respectively.
In Table 5, two different objective functions for each optimization were merged to a single function by the Formula (21). According to the final objective function, GA has produced five schedules for each household and these plans are shown in Figure 3b-f.  The GA optimization results based on the combined objective function are seen in Figure 4. Optimal solutions according to these results have computed as 5th option for home-1, 3rd for home-2, 1st for home-3 and home-4, and 4th for home-5. In order to compare the success of the developed model, a survey has been conducted by 250 participants. Each participant was asked to describe their habits regarding usage for devices. Appliances were scheculed in each houseshold based on the survey results. Then, our objective functions were applied to these outcomes. Table 6 depicts the average of objective function results for each smart home. In the second stage of the proposed model, the Bayesian game was established to construct the NEMS where HEMSs are players in this game. Neighborhood indicators are target functions for NEMS. Indicator values have been calculated with Formula (20). As expressed in Table 7, the first column shows the indicator values based on the data in consumer survey. The other columns depict the indicators considering possible results generated by the GA. Table 7. Survey and indicator results for the smart homes.

Homes Survey ind-1 ind-2 ind-3 ind-4 ind-5
Home When HEMSs are considered individually, optimal strategies become 5-3-1-1-4, respectively (see Figure 4). In the Bayesian game, the NEMS coordinates players (HEMSs) to minimize the fluctuation in total power. To do so, the NEMS allows power transfer among HEMSs as mentioned earlier. The NEMS performs a selection process using the gain function given by (25). The optimum selection results in the neighborhood are given in Table 8. Considering the overall gain, the strategies of the five players should be in the order of 1-3-2-3-4, respectively.  III  II  III  IV  I  S2  II  III  IV  I  III  S3  III  IV  I  III  II  S4  IV  I  III  II  III  S5 In Table 9, indicator values and costs calculated in the survey and Bayesian game were compared. Considering the average of indicators, it was found that the Bayesian game provided 25% efficiency on power. In terms of cost, it is proved that our model presents 8.7% more economical benefit. The net power state of the neighborhood after optimum selection was shown in Figure 5. Due to the maximum energy generated from the PV from 10:00 a.m. to 1:00 p.m., many demands during these hours were supplied and ESSs were charged. The energy generated from PVs in home-1 and home-2 was sold to the grid. In addition, net power has been reduced by transferring excess energy from EVs to homes during peak demands. Although home-4 has not got any EV, it was saturated with transferring energy from EVs in the other homes. The power was sold to the grid at peak hours (7:20-7:50 p.m.). Besides, EVs are charged between 01:00 and 06:00 a.m. when the price is low.

Conclusions
In this study, a new two-stage hybrid energy management system was proposed and designed from scratch. In the first stage, a HEMS structure consisting of DGS, DSS, uncontrollable and controllable devices, was modeled using a GA. The goal of the HEMS was to minimize the total cost according to a dynamic pricing signal. In the second stage, a Bayesian game was established and a NEMS model was constructed that includes all HEMSs. The aim of the NEMS was to minimize total load fluctuation in the neighborhood by allowing power transfer among HEMSs. Then, these models were tested individually using realistic scenarios. The simulation results were thoroughly discussed. In conclusion, the proposed hybrid energy management system proved to be 25% efficient in terms of power and 8.7% efficient in terms of cost.