The Impact of Demand Response Programs on Reducing the Emissions and Cost of A Neighborhood Home Microgrid

: The desire to increase energy efﬁciency and reliability of power grids, along with the need for reducing carbon emissions has led to increasing the utilization of Home Micro-grids (H-MGs). In this context, the issue of economic emission dispatch is worthy of consideration, with a view to controlling generation costs and reducing environmental pollution. This paper presents a multi-objective energy management system, with a structure based on demand response (DR) and dynamic pricing (DP). The proposed energy management system (EMS), in addition to decreasing the market clearing price (MCP) and increasing producer proﬁts, has focused on reducing the level of generation units emissions, as well as enhancing utilization of renewable energy units through the DR programs. As a consequence of the nonlinear and discrete nature of the H-MGs, metaheuristic algorithms are applied to ﬁnd the best possible solution. Moreover, due to the presence of generation units, the Taguchi orthogonal array testing (TOAT) method has been utilized to investigate the uncertainty regarding generation units. In the problem being considered, each H-MG interacts with each other and can negotiate based on their own strategies (reduction of cost or pollution). The obtained results indicate the efﬁciency of the proposed algorithm, a decrease in emissions and an increase in the proﬁt achieved by each H-MG, by 37% and 10%, respectively.


Introduction
In recent years, along with the growth of global demand for electricity, concerns over the growing levels of air pollution and greenhouse gases, and, consequently, the causal link to health issues and global warming have increased considerably.Such concerns resulting from international agreements, such as the Paris Climate Accord of 2016, have led to the promotion and rapid growth in the use of renewable energy devices, especially in the electricity sector.This growth has benefited from the improvement of cost-oriented competitiveness of innovative technologies, groundbreaking, committed policies and better access to financing sources.In addition, issues around energy security, environmental concerns, and an increase of energy demand in developing countries and emerging economies, as well as the need for access to new energies, have also played a part in growing the sector [1][2][3].To this end, it is vital to design a comprehensive model to reduce the costs regarding consumers and producers, as well as lessening the greenhouse gases emission.In fact, an appropriate demand response (DR) model as the most cost-effective and reliable solution can simultaneously reduce the total costs and air pollution, by changing the customers' power consumption and increasing the participation of renewable resources in H-MGs energy consumption.The DR programs are mainly divided into two distinct categories: • Time-based programs are generally utilized to usage over broad blocks of hours.Time-base programs methodologies include Time of Use (TOU), Real-time Pricing (RTP), Critical Peak Pricing (CPP), Critical Peak Rebates (CPR), etc.

•
Incentive-based programs encourage the consumers to alter their energy consumption by proposing the incentives programs offered by the energy provider.The methods include Direct Load Control (DLC), Interruptible/curtail able service (I/C), Emergency Demand Response Program (EDRP), Ancillary Service Markets (A/S), etc.
In the following, a brief overview of literature, and then the flaws of existing solutions and the value proposition of the proposed model are described.
H-MGs, based on renewable technologies, include distributed energy resources, renewable sources, and ES system; the latter can work in two interconnected or detached modes [4][5][6].Combining H-MGs together to create a local structure allows each H-MG to form a coalition and thereby share the power demand and supply in a co-ordinated manner [7][8][9][10].This coalition will increase the productivity of renewable equipment along with load response, reliability and, most importantly, energy independence, all of which ultimately reduce the production of pollutants derived from generation units based on fossil fuels [11].Although electrical energy management strategies with distributed energy resources and ES system at the H-MG level have been extensively studied, there are few studies about neighboring and the local interactions.In [12][13][14][15], the authors proposed a novel approach regarding local energy interactions for the distribution system in which prosumers are persuaded by different balancing premiums to balance their electricity in a local community.Price-responsive generation and demand of an individual prosumer are affected by his/her attitudes and inherent characteristics.In [16,17], EMS based on distributed energy resource is considered, however there is no energy exchange between H-MGs, and consumers of any H-MG are not able to access the sources of other H-MGs.In the present study, H-MGs can share their electrical/thermal power surplus/shortage with other H-MGs, thereby allowing the exchange of power.Each of the H-MGs that have surplus power can display the amount of power along with the price it is willing to accept, offering it for sale among other market players in load energy market.Alternatively, each H-MG that is experiencing a lack of power can make the other players in the load energy market aware of the amount of power required along with the price that it is willing to pay.Finally, according to the bids offered by each of the market players, the exchange takes place.Along with attention to generation, the demand side needs to be considered.DR attempts to achieve a balance between generation and consumption by limiting selection of the loads on the system to which power is provided [18][19][20].It plays a significant role in the effective shift of loads having a certain performance.Due to insufficient attention to DR in residential buildings, M. Pipattanasomporn and Rahman [21] focused on using DR in residential sectors.This paper, while demonstrating DR's effectiveness in controlling and managing the performance of electrical appliances, has shown that DR is a function of the level of comfort and convenience experienced by subscribers.In addition, S. Althaher and Member [22], while indicating the impact of DR on reducing subscriber costs, could prevent the emergence of new peak pricing.Moreover, this work considers a local structure combined with controllable consumers, and attempts to reduce peak demand by the DR strategy.However, it does not provide any solution for calculating the MCP [23,24].Although the DP scheme applied in [25] has managed to maximize the profit of existing agents, such as consumers, by PSO algorithm, the issue of emission reduction has not been investigated.Moreover, the conducted research in [26] shows that utilizing an appropriate DR with a Nash-Stackelberg game approach have led to reaching more utilities for end-users/consumers.In [27,28], a multi-agent system has been presented to evaluate optimal residential DR implementation in a distribution network, in which the main stakeholders including electric vehicles, homes owners, household appliances, and power market are modeled by heterogeneous home agents and a retailer agent.However, the multi-carrier energy system and pollution have not been modeled in this paper.In [28][29][30], a novel home energy management system and a sustainable day-ahead scheduling are presented that enable the residential customers to execute demand response programs autonomously.It eventually leads to reaching an acceptable level of consumers' power consumption and H-MGs costs reduction.In [31,32], the authors recommended the use of incentive-based payments as price offer packages to implement DR programs.Results of the simulation have considered in three different cases for the optimization of operational costs and total emissions of micro-grid without the involvement of DR.In [33][34][35], an optimization strategy for the economic operation of a micro-grid considering DR programs in different scenarios is presented, and it is intended for the aim of minimizing the operating cost of the micro-grid and maximizing the efficiency of renewable energy utilization.In addition, a multi-time electricity price response model based on user behavior and satisfaction is established, and the core value of the model ia to describe the mechanism and effect of participation in electricity price demand response.In [36,37], the applied DR in a multi-carrier energy system (thermal and electrical) leads to decreasing the emission, but the parameters of MCP and DP are in considered in the model.In addition, in [38][39][40], respectively, a DR solution to economic operation issues of grid-connected micro-grid and optimal renewable planning model in conjunction with DR are presented.
To summarize, the following shortcomings can be identified in the existing literature related to the DR schemes including DRP, DRE, and DRPE in the neighborhood H-MG.

•
There is no framework for exchanging power between H-MGs in [16,17].

•
At times when H-MGs have a power shortage, the conditions for purchasing energy from other H-MGs having power surplus are not available [16,17].
In this paper, an EMS has been proposed based on pollution and cost reduction of neighborhood H-MGs.In the proposed algorithm, each H-MG can form a coalition with each other and cooperatively exchange power.Depending on the objective functions of each H-MG, they can share their power and price with other players on the market, based on their DP strategies.The presence of ES and Electric Vehicle (EV), while enhancing reliability, allows the H-MGs to have a significant impact on emission reduction, in addition to maintaining their independence.EMS has tried to achieve its goals by means of a DR strategy applied at three levels: DRP, DRE and, DRPE.It should be noted that the DR schemes applied in this paper belong to the time-based programs.
The major contributions of this paper can be summarized as follows: • It provides a comprehensive and flexible DR strategies based on price, emission, and price-emission.By DRP, DRE, and DRPE, the H-MGs' owners are able to choose dynamically the most appropriate DR programs based on their appliances situations.
• It proposes a multi-objective EMS based on optimization methods and DR strategy to enhance energy independence, decrease air pollution and costs for subscribers, as well as gaining more productivity of non-dispatchable units.

•
It provides a solution to achieve the collective consumers' payoffs, despite the presence of players with different levels of ownership and goals.
The remainder of this paper is organized as follows: In Section 2, we briefly describe the general idea.In this section, the network under study and the primary assumptions are specified.Then, in Section 3, the structure of the proposed algorithm is presented.In Section 4, the mathematical formulation of problem is introduced.Finally, in Section 5, the results obtained from the proposed approach are shown, and conclusions are given.

Description of General Idea
As shown in Figure 1, the case study is a neighborhood grid consisting of several H-MGs, and each H-MG comprises non-responsive load and Distributed Energy Resources (DERs) including responsive load demand, Energy Storage (ES), dispatchable unit, and non-dispatchable unit.Each H-MG must first respond to its loads according to the non-dispatchable units output, and, ultimately, if it has a deficit in electrical/thermal power, it will be compensated by obtaining power from other H-MGs or vendors.On the other hand, if it has an excess in power generation, the H-MG sells the surplus to other H-MGs or purchasers.Therefore, each player must make a comparison between the prices offered by other H-MGs and retailers to select the optimal price offer for this competition.Producers and consumers have their own goals, buying and selling, accordingly.Therefore, each manufacturer is seeking to raise its profits by selling the highest amount of power produced to other H-MGs and retailers.On the other hand, each consumer tries to buy low-cost products to reduce their own outlay.Furthermore, since ER is the main objective of the strategies being presented in this paper, each H-MG should, if faced with a lack of power generation, firstly detect its deficiency through the ES, and then determine whether the existing dispatchable units violate the pollution indicators.Finally, it should solve the problem of power shortage according to the DR constraints and through the use of dispatchable units.Ultimately, power shortage will be mitigated by purchasing from other H-MGs and retailers.To meet the ER objective function, each of the H-MGs that are lacking in power should first provide their own deficiency from surplus generation of other H-MGs.

The Structure of Proposed Algorithm
In this paper, a multi-objective EMS based on optimization methods and DR strategy is proposed to enhance energy independence, decrease air pollution and costs for subscribers while improving their comfort and convenience, and gain more productivity of non-dispatchable units.As shown in Figure 2, the proposed structure consists of TOAT units to estimate the uncertainty regarding input data including solar irradiation, system sell price, system buy price, and MCP.The structure of EMS-DR is multi-level and therefore it is possible to find optimal points for satisfying the objective function of the problem using meta-heuristic algorithms including BAT [41], DE [42], and PSO [43].With its DR strategy applied at different levels, EMS has focused on ER and lowered consumer spending.The purpose of this paper is not to evaluate the methods of comparative optimization, but to implement different optimization methods to identify the comparative strengths and weaknesses of the approaches.In addition, depending on the benefits and detriments of each of these techniques, optimization methods may be identified.In other words, in this paper, rather than proposing a completely new method, the author's aim is to show that, for different criteria and taking into account a specific objective function for each of the players, users of the proposed structure can make the correct decision in choosing a method.

EMS-DR Unit
Creating a balance between supply and demand, dropping the courier and reducing the costs by shifting the power from the expensive periods to cheaper periods, are some of the most important effects of DR that the proposed EMS has been able to take advantage of.In this paper, it is assumed that the consumers and H-MGs have already agreed on a short/long-term contract with an energy provider or utility grid, therefore any discussion revolving around the contracts and intellectual property is beyond the scope of this paper.In addition, in this paper, it is not directly investigated the discussion of DR schemes benefits for the consumer, however, it emphasizes the positive impact of DR programs on decreasing H-MG emissions and increasing H-MGs profits derived from following the DR schemes.Prior to explaining each DR program, it should be mentioned that each DR scheme including EMS-DRP, EMS-DRE, and EMS-DRPE are applied just for an H-MG throughout the paper.Demand response based on price (EMS-DRP), demand response based on emission (EMS-DRE), and demand response based on emission and price (EMS-DRPE) are used for H-MG#A, H-MG#B, and H-MG#C, respectively.The proposed EMS algorithm has used DR at three levels, described as follows: • EMS-DRP: At this level of EMS, cost reduction has been considered through the power demand shift.According to Figure 3, each H-MG must first respond to its power demand through embedded non-dispatchable units.If power demand is lower than power generation by non-dispatchable units and the power shortage is higher than the minimum CHP generation, then CHP goes into orbit.Two things happen in this case: (i) due to CHP, the power shortage will be lost and a surplus of power generation will occur; or (ii) the shortage of generation will continue to be less intense.If there is still a shortage of generation, ES will be discharged according to ES capacity and constraints.If there is still a problem with power dissipation in the ES, then according to the DR constraints, power shortages are shifted to other time when the cost of power is cheaper.It should be noted that the EMS only can shift a certain amount of power to future periods, otherwise it would have to generate a power loss through load energy market.In this case, the purchase priority is with other H-MG neighbors, followed by the retailer, due to the fact that H-MGs are able to accrue the profit whilst the lack of purchasing from retailers also reduces the pollution caused by traditional electricity generation systems.With these interpretations, if the CHP enters the circuit and the power generation surplus occurs, the EMS can charge ES according to the constraints of the issue, and respond to the DR whilst selling its excess power in load energy market, which is the priority of purchasing with Other H-MGs and then retailers.For this purpose, H-MGs should position their pre-bid price at a level that is lower than the retailers offer.Flowcharts of the electrical sections are shown in Figures 3a.As depicted in Figure 3b, DR is not considered in the thermal sector.In the thermal sector, in the first place, TSP and CHP have an obligation to respond to the thermal loads.If there is a lack of thermal power, since there is no emission constraint on H-MG #A, then GB enters the circuit and responds to loads.• EMS-DRE: In this section, EMS has focused its efforts on reducing pollution using DR.Emax is introduced as a pollution indicator.In more detail, let Y be a finite set of random variable regarding the pollution of a large-scale power network (Emission of Electricity Consumption in UK Power System [44]) with finite outcomes y 1 , y 2 , ..., y n .Hence, Emax equals E[Y] representing the expected value of Y.As shown in Figure 4a, if the need for using CHP arises, it must first be checked that the amount of power shortage is higher than the minimum CHP generation power, and then check whether the CHP inflow circuit exceeds the Emax pollution index.If it passes through Emax, the algorithm allows benefiting the CHP only to the extent that it does not violate Emax.Considering this important constraint, and with the entrance of CHP to the orbits, the reduction of the power shortage or surplus of power generation occurs, with the algorithm continuing to function as in the previous section.In the thermal sector, although DR is not taken into account, considering that the DR applied in H-MG #B tries to reduce pollution, and with making the use of GB, the pollution will increase, therefore GB enters the circuit with limitations.As shown in Figure 4b, GB can only generate thermal power just insofar as it does not exceed the Emax index.
• EMS-DRPE: In this section, the proposed algorithm controls both price and pollution using DR.For this purpose, the "adjustment point" is considered for the price of power to serve as an indicator of demand shifts.At each time interval, the MCP value, with due consideration given to uncertainty, is first examined.If the MCP value is higher compared to the adjustment point, and provided the ES has a discharge capability, it discharges the ES algorithm.Furthermore, if there is still a power shortage, it will transfer part of the load according to the defined constraints in proportion to the generation state of the non-dispatchable units and loads.However, if the MCP value is small, and the power shortage is greater than the minimum CHP generation, the algorithm will measure the pollution condition in proportion to Emax.If the amount of pollution resulting from the entrance of CHP to the circuit is less than Emax, an excess in power generation or reduction of power shortage occurs, in accordance with the situation, as in the previous sections of the algorithm.It should be noted that, if, as a result of the entrance of CHP to circuit, the pollution breaks out of Emax, an algorithm that is less than or equal to Emax will allow CHP to operate.
Figure 5 shows the EMS-DRPE electric flow chart section.It should be remarked that the thermal section of H-MG #C is quite similar to the H-MG #B.

MCP Unit
In this unit, information about electrical/thermal power and price offers for each of them is extracted by the DP strategy.DP enables the optimum price point to be obtained.As shown in Figure 6, supply and demand curves of a good intersect at one point, which is an optimal MCP point.In this paper, the predicted MCP is extracted from [45,46].

Taguchi Orthogonal Array Testing (TOAT) Unit
Due to the availability of renewable energy, H-MGs will reduce air pollution, in addition to power demanded from the grid.However, the inherent uncertain nature of these devices is a major challenge.Since sunlight is not permanently available and depends on the atmospheric conditions, it is very difficult to predict exactly how much power a H-MG produces.On the other hand, sudden changes in power demand overnight are also associated with uncertainty.In this paper, the problem of uncertainty has been investigated using TOAT.The high speed of the calculation is unique to the TOAT.Detailed descriptions of how the operation and uncertainty calculations are formulated are outside the scope of this paper, and the reader is referred to the following sources for further information [47].

Mathematical Implementation of the Problem
In this section, the problem formulation is presented by the key factors in market structure based on transitional energy.This framework is simply extensible to other distribution systems with high levels of customer participation.

Objective Functions of the Participants in MO-TE
The defined objective functions are based on maximizing H-MGs' and retailers' profits and minimizing the consumers costs and pollution.In more details, there are five objective functions as a multi-objective problem concerning total profit of Micro-grid (Equation ( 1)), profit of retailer (Equation ( 2)), the costs of H-MGs as Equation ( 3), the pollution function as Equation ( 4), and, finally, the costs of emitting the pollution as Equation ( 5), which is derived from consuming the thermal power.
Equations ( 6) and ( 7) represent the total power generated by electrical/thermal generators during each time interval; this quantity must be equal to the total demand of the electrical/thermal consumers.

Retailer constraints
Equation (8) shows the cost resulting from electrical power purchased from the retailer to the H-MG n, while Equation (9) presents the lower and upper bounds of retailers offer price for purchasing power to the H-MG n.CO In addition, Equation ( 10) is the revenue resulting from selling electrical power from the H-MG n to the retailer, whereas Equation (11) shows the price bid range for sales of power by the retailer to H-MG n.
Equations ( 12) and ( 13) show the exchanged power constraints between H-MG n and retailer.In addition, Equation ( 14) represents the binary decision variable for the retailer.

P
Equations ( 15) and ( 16), respectively, are the function regarding the pollution of the retailer and the cost of pollution causing by purchasing from retailers.In Equation (15), d i E is the retailers' pollution factor, which belongs to closed interval [0,1].
In Equation ( 16), α is calculated from the relations in Equations ( 17) and (18).The coefficient of price fine (i.e., Max-Max type) equals the ratio of maximum fuel cost to the maximum emitted pollution level.This coefficient, compared to other coefficients, leads to more pollution reduction.Meanwhile, the Min-Max price is equal to the ratio of the minimum fuel cost to the maximum amount of pollution released.This type of fine coefficient will minimize the cost of fuel compared to other fines.

H-MG n constraints ES and TES constraints in H-MG n
The cost of charging ES is obtained from Equation (19), where CO ES ch h,e,n , U ES h,e,n ,π ES ch h,e,n , and π h,e,n , respectively, show the cost, revenue (utility), and price bid resulting from buying/selling electrical power by ES in H-MG n.Equations ( 23)- (25) present ES maximum and minimum charge/discharge in H-MG n.Equations ( 26) and ( 27) are the charge/discharge maximum limits for the energy in Equation (28) Equation ( 29) depicts the cost resulting from buying thermal power by TES in the charging mode, while Equation ( 30) is the price bid interval for buying thermal power by TES.

CO TES
In Equations ( 33)-( 35 Equations ( 36) and (37) show the maximum discharge/charge limits for the energy in TES, while Equation ( 38) presents the energy equilibrium in TES.
EV constraints in H-MG n Equation (39) illustrates that if m EV h,n = 1, then the battery can be charged between PEV ch n and PEV ch h,e,n , as the lower and upper bounds, respectively.Equation (40) states that SOC EV h,n of the automobile battery during each time interval related to H-MG n, must be less than its maximum value.It should be noted that Equation (41) is the automobile battery power balance constraint.If the EV is unplugged or once SOC EV h,n has reached to the highest value, the charging process will be finished.In addition, Equation (42) indicates that, when the battery has been fully charged, no power is required to charge.
Equation ( 43) is the cost of buying electrical power while Equation (44) indicates the offer price range for power bought by EV.
CO EV ch h,e,n = π EV ch h,e,n × P EV ch h,e,n

ESP constraints in H-MG n
The ESP generated power limitation is as shown in Equation (45).

PESP
TSP constraints in H-MG n Equation (48) shows the generated thermal power income of Thermal Solar Panel (TSP), and Equation (49) shows the range of price bid for power sold by TSP.
Equation ( 53) is the cost as a result of power generation by CHP.Equation (54) shows the price bid range for power generated by CHP.In addition, Equations ( 55) and (56) state the revenue resulting from selling electrical and thermal powers generated by the CHP.
Equations ( 57)-(59), respectively, are the CHP pollution function, the cost of pollution causing by purchasing from CHP and the cost of the fuel consumed.

GB constraints in H-MG n
The limit of the power generated by GB is shown in Equation (60).
Equation ( 61) shows the cost resulting from thermal power generated by GB while Equation (62) presents the amount of fuel consumed using GB and Equation (63) determines the price bid range for selling power through GB.
The revenue resulting from thermal power sold by GB is shown in Equation (64).
Equations ( 65)-(67), respectively, are the functions regarding GB pollution, the cost of pollution causing by purchasing from GB, and the cost of fuel consumed.

Consumer constraints DR constraints
Equation (68) shows that the amount of shift-able power must be less than or equal to the difference between the total consumed power and the total generated power.The linear inequality in Equation ( 69) indicates the amount of available power that can be allocated to the DR.Equations ( 70) and (71) show that the DR limit between two consecutive intervals must not exceed a certain value.
The appliances of H-MGs in each time interval h are divided into two divisions, namely essential as non-shift-able (NSH), and shift-able.Let ϑ Tot,n = [P

APP(γ) n,h
] be the total load of H-MG n, at time h.In addition, APP(γ) is γth appliance and APP(NSH) is the set of all NSH (non-shiftable) appliances.Equation (72) denotes the total load demanded/produced of H-MG n at time h.
In Equation ( 73 For each H-MG n at time h, DR constraints consist of three divisions, namely DRP, DRE, and DRPE constraints, which are described in Equations ( 74), (75), and (76), respectively.

ATL and AEL constraints
Equations ( 77) and ( 78) are the costs resulting from electric and thermal power purchased by AEL and ATL.In addition, Equations ( 79) and (80) present the price bid interval for power purchased by AEL and ATL. max(π

TD constraints
Equation ( 81) is the cost of thermal power bought by Thermal Dump (TD) while Equation ( 82) states the offer price range for power bought by TD.

DW constraints
The modeling of DW are presented in Equations ( 88)-(91).In addition, Equations ( 90) and (91), respectively, show the cost resulting from buying power by DW and the price bid interval for buying power.

HHW constraints
The modeling of HHW are presented in Equations ( 92)-( 96).When the HHW temperature lies between the lower and upper bounds, ŤHHW , the HHW stays in off mode.Therefore, the temperature decreases due to the heat generation (Equation ( 93)).

Results and Discussion
Computer simulations were carried out using the MATLAB software environment running on a personal computer with a 2.5 GHz CPU with 8.0 Gigabytes of memory to perform the multi-objective problem linked with MATLAB tools as a support to coordinate the execution of these problems, store data and make the graphical representation.The simulated period was 24-h.In this study, the defined objective function for all optimization methods was the same and the performance of all proposed optimization methods, in responding to specified objective functions for all players, were investigated.It should be noted that the amount of power produced and consumed by renewable generators and each H-MG, respectively, were not the same.Therefore, comparing the results per each H-MG was not possible due to the amount of power consumption, power generated, and several variables being different per each H-MG.As shown in Figure 7a, the peak value is shifted to non-peak intervals using the BAT method in H-MG #A.Since in H-MG #A, DR is based on price, it is expected that the highest DR+ and DR-occur in this H-MG.As ahown in Figure 7a, the highest DR+ and DR-values among H-MGs belong to H-MG #A, so that comparing H-MG #A with H-MG #B and H-MG #C reveals a shift in the cost of power from expensive 17% to relatively cheaper 12%, a reduction of 5%.In general, H-MG #A has the best performance in DR+ and DR− regarding the BAT method.However, the lowest DRcontent in the H-MG#A has been attributed to the PSO method, which indicates the low efficacy of this method in the power demand shift from a high-cost period to a much lower price range.
In H-MG #B, the two methods of BAT and DE have the same performance at DR+ .However, in DR-, the sum of both methods was not as large as the DR-in PSO method.The PSO method with a 52% power demand shift has shown the strongest tendency for power demand shifts.In H-MG #C, where DR is based on price and pollution levels, all three methods contribute the same amount in DR+.However, the DE method, with a 50% contribution in the power demand shift, has been able to capture a high percentage of DR.The percentage of electrical power generated by each of the optimization methods is in accordance with Figure 8. Evidently, each of the optimization methods has used existing resources in proportion to their power demand, with CHP playing a very significant role.It should be noted that, despite the different generation rates of each H-MG, in general, the balance of power generated in each H-MG should be considered independently, and also in the entirety of the case study.As shown in Figure 8, optimization algorithms have used most of the ESP generation corresponding to the highest sun exposure times, which has helped considerably in reducing the level of air pollution.Furthermore, the highest level of generation has been related to CHP, whose main reason is to maintain the energy independence of each of the H-MGs.One of the major goals of the optimization techniques is to allow H-MGs to independently produce and supply their power requirements while meeting all constraints.As can be seen, the grid also plays a significant role in providing the generation powers.Consistently maintaining the energy independency in H-MGs is of great importance, but due to pollution constraints, optimization methods based upon selecting the minimum amount of pollution generated between the grid and CHP, have selected Grid to provide their required power.This is illustrated in Figure 9.As shown in several intervals, both CHP and the grid, have provided power for H-MGs, due to pollution constraints.CHPs can only produce enough power to meet the requirement of not exceeding the pollutant index.Therefore, the algorithm evaluates the amount of power required by H-MG and the amount of power generated by power purchases from the grid to purchase power from the network.The percentage of thermal power generated by each of the optimization methods is in accordance with Figure 9.In this section, similar to the electrical sector, the thermal equilibrium of each H-MG, as well as the set of H-MGs, must be met by implemented optimization algorithms.
As seen, GB has entered the service at times when the amount of TSP generation has been decreased and a growth in the load has occurred.Of course, the maintenance of GBs is subject to compliance with the pollution constraints, since GB can only generate heat to a degree that does not rule out the pollution index.
The process of reducing air pollution by each of the PSO, BAT and DE methods is shown in Figure 10.As can be seen, in more than 90% of the intervals, the proposed algorithm succeeds in reducing pollution.In H-MG #A, DR has been based on price.In this section, the algorithm is only required to shift the power to cheaper times.In H-MG #A, the best performance has been to reduce the pollution associated with the DE method, but, since the maximum MCP price has been between 16:00 and 22:00, the algorithm should reduce the power demand surplus.Consequently, the algorithm in this interval should not buy the power from the network whilst using the least amount from CHP and GB.Therefore, considering Figure 10a, it is evident that the PSO method has had the best performance in this interval.The algorithm has been able to reduce pollution by a reduction in the use of CHP and GB compared to the pollution index of 73%.In H-MG #B, DR is programmed based on pollution.In this H-MG, the algorithm allows CHP and GB to reach orbit so that the pollution index is not compromised.Despite the fact that all methods managed to reduce the pollution level to below 100%, the PSO method had the best performance in ER, which had a 64% reduction compared to Emax.The reason why the H-MG #B was less successful than the H-MG #A in the ER was that there was a 35% increase in load in the building B, and the algorithm had to use the maximum CHP and GB (taking into account the constraints).In H-MG #C, DR has been set based on price and pollution.In this H-MG, pollution was reduced over 87% of the timeframe.In this H-MG algorithm, in addition to a considerable reduction in costs (as shown in Figure 11, there has also been success in reducing pollution.In this building, the best performance is related to the DE method, which has been able to reduce pollution by about 60%, relative to the air pollution index.In general, the DE method has the best performance in terms of pollution reduction, whereas the PSO method has the weakest performance.The electrical and thermal MCP values obtained from the simulation using various methods are shown in Figure 11a,b respectively.For better analysis, the 24-h simulation interval is divided into four 6-h intervals.As shown in Figure 11a, all of the optimization methods have succeeded in reducing the MCP, so that for all time periods, the calculated MCP was lower than the MCP prediction.According to Figure 11a, in the first time interval (00:00-06:00), the best performance has been achieved by the DE method.In this interval, the BAT method has had a weaker performance than the other two methods.The DE method compared with predicted BAT and MCP resulted in 5% and 33% reduction of MCP, respectively.In the second period (18:00-12:00), the best performance was related to the PSO method.In this interval, the lowest MCP reduction was related to the BAT method.PSO method has a better performance than that of the BAT, which yielded 22%.In addition, the PSO approach compared to the MCP prediction has a 44% decline.In the third period (12:00-18:00), the PSO method has been able to maintain the MCP minimization trend, which is 12% higher than the DE method, which has the lowest reduction, and 39% better than the MCP prediction.
In the last period (from 18:00-24:00), the best performance was related to DE.In this range, DE has shown the best performance while the BAT has the weakest performance.DE was 28% and 47% lower than predicted by BAT and MCP, respectively.In general, the PSO and DE methods, with less than 2% difference in performance, have displayed the best results while BAT yielded the weakest.Thermal MCP is shown in Figure 11b.As seen in the first interval, the DE method had the best performance compared to PSO and BAT, so that the DE method was 49% better than the PSO, the latter having the weakest performance.In the second interval, the best performance was related to the BAT method and the weakest associated with the PSO, with a functional difference of about 55%.In the third period, the weakest and strongest performances were related to the BAT and DE methods, respectively.During this time interval, the DE method has shown 38% better performance than the BAT.In the last interval, i.e., the fourth interval, as in the previous interval, the strongest and weakest methods were DE and BAT, respectively.In this range, the DE method is 25% better than BAT.In general, as shown in Figure 11b, the best performance for decreasing the thermal MCP was related to the DE method.The convergence characteristics of the proposed algorithms were compared with each other, as demonstrated in Figure 12.As shown in this figure, each algorithm was executed for 100 iterations as an accuracy validation criterion.This figure indicates that the proposed algorithm based on the BAT method outperforms the other optimization techniques in convergence speed; however, the proposed algorithm based on DE method achieved a better performance from optimality of objective function point of view.The obtained maximum profit for DE and BAT methods are £8.5 and £7.8, with the corresponding CPU times of 8.085 s and 7.96 s, respectively.According to the results in Figure 11a,b, the most successful method for reducing electric and thermal MCP is the DE method.According to the use of several optimization methods, the standard deviation, minimum and maximum profits and average price of each method (in 50 epochs) are shown separately in Table 1.

Conclusions
In this paper, the DR algorithm has been proposed to reduce the costs of H-MGs, reducing air pollution and optimizing the use of electrical/thermal resources available in H-MGs.The timing of household appliances and electrical machinery is also included by considering both the technical and economic constraints.The DR-based structure was followed by demand side management, peak demand/load reduction, lowering market price and reducing air pollution.In addition, using optimization methods, an attempt has been made to optimize the objective functions of each H-MG.The indicated results and proposed structure capabilities were compared to input parameter changes using several methods.In this paper, each H-MG can form a coalition with each other, negotiating with each other in a way that satisfies its objective functions, including reducing/increasing their costs/profits, along with supplying the demand.The results show that DR, with optimal control of ES and RES, reduced the greenhouse gases emission by almost 37% and increased the total profit of H-MGs by 10%.It is easy to use the proposed algorithm for various structures with different objective functions, as well as a diverse range of generation and consumption devices.Application-wise, according to the kind of home appliances (thermal or electrical), the smart buildings, H-MGs owners and tenants can contract with an energy provider or utility grid for which scheme they want to purchase.To this end, the energy providers try to provide incentive programs to make the consumers interested (for example, the consumers by participating in DR programs, and as a result by changing their consumption pattern, help the energy provider to control total demand, thus consumers can reduce their bill).This study can be extended in the following ways: (1) evaluating other schemes of DR because the consumers feel more comfortable with the incentive-based programs; (2) mechanism design for the coalition formation between rational agents and generation units (DGs); (3) proposing the competitive approaches to model the interaction between the agents in the electricity market; (4) calculation of tax based on CO 2 (Carbon Tax); and (5) the impact of occurring faults in energy management system.

Figure 1 .
Figure 1.A schematic of the general idea.

Figure 2 .
Figure 2. Flowchart of the proposed algorithm.

Figure 6 .
Figure 6.The schematic diagram of Market Clearing Price (MCP).
is expressed as demand position vector of load APP(γ) of H-MG n at time h.If PO APP(γ) n,h = 0, the APP(γ) has been shifted to another time, otherwise it equals 1. τ )-(87) state the modeling of REF.When the temperature lies between two minimum and maximum amount, ŤREF n ≤ T REF h,n ≤ TREF n , the refrigerator stays in off mode.Hence, the temperature increases because the compressor of refrigerator is working (Equation (84)).

Figure 8 .
Figure 8. Percentage of electrical power produced by the implemented methods.

Figure 9 .
Figure 9. Percentage of thermal power produced by the implemented methods.

Figure 11 .Figure 12 .
Figure 11.Electrical/thermal MCP profile at a time interval under 24-h operation by different optimization methods.

CHP+TSP=Consumption Yes t=t+1 CHP+TSP<Consumption No Shortage is less than at least GB Yes GB goes into orbit No GB production is more than shortage TES is capable to charge Charge TES Yes No Allocate power to TD No Surplus Production? Allocate power to TD Yes No Yes TES is capable to charge No Purchase from a virtual source No Discharge TES Yes There is still a shortage power Yes Purchase from a virtual source Surplus Production Lack of production No Start Production= Consumption Yes t=t+1 Production > Consumption No Lack of power is greater than the minimum CHP production Yes CHP goes into orbit Yes The amount of CHP production is greater than the power shortage Shifted Load<Surplus production Allocate full power to DR Yes No Can the battery be charged? Charge ES Allocate power as much surplus production to DR No Yes Surplus Production? No Sell to network or assign power to EWH No Yes The battery is capable to charge No DW and EV request the power Shift to other times No No Purchase from market Yes Discharge the battery Yes There is still a shortage power DW and EV request the power Yes Shift to other times No Purchase from market Yes Surplus Production Lack of production No Electrical Section b) Thermal Section Yes A A Yes No a) Figure 3.
Flowchart of EMS-DRP.

CHP+TSP=Consumption Yes t=t+1 CHP+TSP<Consumption No Shortage is less than at least GB Yes GB goes into orbit GB production is more than shortage TES is capable to charge Charge TES Yes No Allocate power to TD No Surplus Production? Allocate power to TD Yes No Yes TES is capable to charge No Purchase from a virtual source No Discharge TES Yes There is still a shortage power Yes Purchase from a virtual source No Yes Surplus production Lack of Production Pollution resulting from the GB passes through the index NO NO The GB enters the circuit, not passing through the index
Yes A (b) The thermal sectionFigure 4. Flowchart of EMS-DRE (Electrical and Thermal Sections).

Production= Consumption Yes t=t+1 Consumption>Production No Lack of power is greater than the minimum CHP production CHP goes into orbit Yes The amount of CHP production is greater than the power shortage Shifted Load<Surplus production Allocate full power to DR Yes No Can the battery be charged? Charge ES Allocate power as much surplus production to DR No Yes Surplus Production? Yes Sell to network No Yes The battery is capable to charge No No Discharge battery Yes There is still a shortage power Yes Purchase from market Surplus Production Lack of production No A Pollution resulting from the CHP passes through the index No The CHP enters the circuit, not passing through the index Yes Lack of power is greater than the maximum amount of shiftable power Yes Shift to other times No MCP> MCP` Yes MCP`: Adjustment Point No No No Yes
Figure 5. Flowchart of EMS-DRPE (Electrical Section).
e,jn + U ESd h,e,n + U h,ht,in + U , respectively, are income/cost caused by selling/purchasing the electricity from/to retailer in H-MG n.In addition, CO k,n h,h , CO c,n h,e are, respectively, electricity costs concerned to k and c consumer in H-MG n.In addition, E h,ni indicates the pollution caused by retailers and CHP and GB.CO h,F , CO h,ni , respectively, represent the cost of fuel and pollution.
), TES maximum and minimum charge/discharge limitations are shown.
(47)tion(46)shows the revenue as a result of the electrical power generated by ESP, whereas Equation(47)shows the price bid range for power sold by ESP.

Table 1 .
Comparison of deviation, average and minimum cost between applied optimization methods.

Number of Run Minimum Profit Maximum Profit Averege Profit Standard Deviation
electricity/heat/time interval [1,2,...,24]/H-MG number, n∈ {1, 2, • • • , g} /Emission/Fuel i∈ {CHP, GB, TSP} thermal distributed energy resources j∈ {ESP, CHP} electrical distributed energy resources c∈ {DW, EV, REF, AEL} electrical consumers k∈ {HHW, ATL, TD} thermal consumers Ω∈ {CHP, GB, Retailer} Producers that emit pollution Constant Values ŠOC m , ŜOC m , Pm , Pm minimum/maximum values of SOC/power during m charging and discharging mode, m∈ {ES d , ES ch , EV d , EV ch , TES d , TES ch } ToE m total value of m energy capacity T f , Ť f maximum/minimum of f temperature, f∈ {REF, HHW} T 0 , T RED , T I NC initial temperature/the amount of temperature reduction each time the REF compressor is turned on/the amount of temperature increase each time HHW is turned on Pe/ht,i , Pe/ht,i minimum/maximum values of electrical thermal power i binary variable of retailer, electrical energy storage, thermal energy storage, demand response P h,e,c , P h,ht,k electrical/thermal power consumed by l/c at time h P ht,e,i , P ht,e,j electrical/thermal power generated by j/i at time h market clearing price by using the optimization method of W={BAT, DE, PSO} (£/kWh) hMCP prediction value during each time interval h (£/kWh)