Efﬁcient Energy Optimization Day-Ahead Energy Forecasting in Smart Grid Considering Demand Response and Microgrids

: In smart grid, energy management is an indispensable for reducing energy cost of consumers while maximizing user comfort and alleviating the peak to average ratio and carbon emission under real time pricing approach. In contrast, the emergence of bidirectional communication and power transfer technology enables electric vehicles (EVs) charging/discharging scheduling, load shifting/scheduling, and optimal energy sharing, making the power grid smart. With this motiva-tion, efﬁcient energy management model for a microgrid with ant colony optimization algorithm to systematically schedule load and EVs charging/discharging of is introduced. The smart microgrid is equipped with controllable appliances, photovoltaic panels, wind turbines, electrolyzer, hydrogen tank, and energy storage system. Peak load, peak to average ratio, cost, energy cost, and carbon emission operation of appliances are reduced by the charging/discharging of electric vehicles, and energy storage systems are scheduled using real time pricing tariffs. This work also predicts wind speed and solar irradiation to ensure efﬁcient energy optimization. Simulations are carried out to validate our developed ant colony optimization algorithm-based energy management scheme. The obtained results demonstrate that the developed efﬁcient energy management model can reduce energy cost, alleviate peak to average ratio, and carbon emission.


Introduction
The traditional power system is inefficient because it entirely depends on fossil fuels, and having centralized generation that is far away from consumers. In these circumstances, the generated electricity needs to be transmitted and distributed to consumers via transmission and distribution lines over long distances, spending many resources on construction, maintenance of all systems involved and high levels of technical losses [1]. According to [2], centralized power systems suffer from severe transmission and distribution energy losses because of long distances between consumers and generating stations. Furthermore, centralized generation usually causes more environmental pollution than distributed generation technologies. From the consumer's point of view, practically, electricity is used in unintelligent manner without control. Keeping in view both perspectives, new The authors of [11] introduced the deterministic method to schedule the operation of appliances and charging/discharging of EVs. Furthermore, EVs are considered mobile storage. In [12], authors developed a building energy management strategy for peak energy consumption mitigation. They considered ESSs and EVs as storage devices to mitigate fluctuations accompanied by RES and improve building energy efficiency regarding cost minimization. A hybrid energy system of PV, WT, and ESSs is developed with day-ahead energy forecasting in [13]. Furthermore, they considered diesel generator as a backup for power generation; however, power is produced at high cost and pollution emission.
The valuable research reviewed above either focused on load scheduling or charging/discharging scheduling of ESSs and EVs or failed to fully utilize beneficial aspects of smart grid technologies and DR program implementation. Some studies used a diesel generator as a backup, which is not appropriate for RES-based microgrids. Some solutions such as load shedding may cause user frustration, and minimize welfare and system efficiency. With this motivation, this work proposes an efficient management strategy to schedule user activities, ESSs and EVs are connected to a smart microgrid. In addition, we assess a smart home and microgrid equipped with PV panels, WT, electrolyzer, hydrogen tank, ESSs, and EVs connected to the external power grid. As a backup resource, a MGT is employed in place of diesel drive subject to cost and carbon emission minimization concerns. We use mobile storage (EVs) and static storage (ESSs) simultaneously to cater for uncertainties in EVs (parked in home or goes out on driving), and ensure the reliable provision of electricity. Moreover, a prediction model based on modified Enhanced Differential Evolution (mEDE) and Artificial Neural Network (ANN) is developed for microgrid generation capacity accurate prediction instead of assuming. The main contribution and novelty of this paper is outlined below.
• An efficient energy management scheme is proposed, which considers the RTP curve with variations that systematically schedule appliance operation and charging/discharging of EVs to maintain a balance between energy supply and demand. • Ant colony optimization (ACO) algorithm is adapted, which takes into account constraints, occupant energy consumption pattern, users priorities, and uncertainties in the presence of RTP to schedule load and EVs charging/discharging for efficient energy management. • Adapted ACO algorithm successfully solves the presented problem, allowing a high monetary reduction in the energy cost paid by consumers, alleviating the peak formation in electricity demand, minimizing carbon emission, and improving the comfort of the users. • For efficient energy management, an accurate forecast model ANN based on mEDE (ANN-mEDE) is developed to forecast a generation profile of microgrid using weather information and mathematical models of the WT and PV. • Simulation results demonstrate that the newly devised scheme based on the ACO technique is effective, which considerably reduces the consumer's cost, PAR, and peak electricity demand reduction in the commercial grid.
The rest of the paper is structured as follows: Section 2 presents related work. In Section 3, a proposed efficient system model is discussed. Section 4 presents mathematical modeling of the proposed system model. The problem formulation is presented in Section 5. The simulation results are presented in Section 6 and finally in Section 7, the paper is concluded.

Related Work
Several research works have been conducted over the last few decades in the literature to address energy management problems in a smart gird. To solve energy management problems, many heuristic, mathematical, and controller base methods are developed in the literature, which are discussed in detail as follows.

Mathematical Techniques
In [14], the authors power usage scheduling framework based on Mixed Integer Linear Programming (MILP) to reduce energy cost and alleviate PAR. The authors in [15] proposes a game theory-based appliance scheduling framework for electricity cost and peak energy demand reduction. However, the user frustration level is not taken into consideration. The authors of [16] proposes a scheme for residential sector based on MILP technique to analyze EVs bi-directional flow. In [17], authors mitigate the cost of electricity in a smart house and determine the modes of operation of various loads; an exact solution technique is used to retain the surplus electricity from RESs in batteries. To minimize overall energy bill in the microgrid, an optimal energy management model based on MILP is presented [18]. The authors use the Power Grand Composite Curves (PGCC) technique for adjusting system functioning in response to short-term energy requirement, and their study provides a unique way for identifying appropriate Power Management Strategies (PMS) in RES-based smart grids. The authors of [19] evaluate prosumers-based Energy Management and Sharing (PEMS) as well as the issues that come with it. It will assist in the interpretation and analysis of the prosumers effect on future smart grids. Their study gives a detailed evaluation of these goals, PEMS in the smart grid environment, and its impacts on power system reliability and energy sustainability are studied. In [20], authors developed a technique based on the MILP paradigm, employed in this project to provide an optimal solution in terms of tasks such as energy usage and renewable resource management. The suggested technique achieves an optimal schedule under dynamic electrical limitations while maintaining thermal comfort based on user requirements. The mathematical and deterministic methods suffer from system and computational complexity.

Controller-Based Methods
Researchers adopted controller-based methods to resolve problems accompanied with deterministic methods. For example, in [21], the authors presented a Distributed Model Predictive Controller (DMPC) for consumers and EUCs DSM. The smart grid have generating units such as RESs, ESSs, and smart load. The DMPC schedules the smart load for efficient DSM. The authors of [22] proposed an integration and control automation of RESs such as a PV plant, a solid oxide fuel cell with battery, and load in smart grid. The Energy Management System (EMS) is based on Proportional Integral (PI) and Adaptive Neuro-Fuzzy Inference System (ANFIS) techniques to effectively balance supply and demand. A DMPC method is developed for grid-connected cooperative energy management in [23]. The proposed DMPC's optimization results are similar to Centralised MPC (CMPC) Pareto solutions according to a real-time hardware-in-the-loop, while the computation speed is significantly faster than CMPC. The authors in [24] proposed an energy management scheme to forecast interrupted data for a microgrid with a centralized dispatching mechanism. The proposed energy management scheme is based on MPC and ensemble learning network approaches. A novel coordinated MPC method is developed that schedules the operation of the microgrid while considering the variations of stochastic RESs as well as meteorological circumstances [25]. A dynamic energy management system based on MPC is developed for a power grid-connected microgrid linked to and serving a residential area [26]. The dynamic energy management system collects data from various components of the electrical system via a smart metering system. However, the controllerbased methods are computationally intensive and become too slow for energy optimization.

Stochastic Techniques
To resolve the problems accompanied by deterministic and controller-based methods, stochastic techniques have emerged as a promising solution. For instance, in [27], the Genetic Algorithm (GA) based non-sorting scheme was adopted for scheduling household with primary objectives such as carbon emissions, power usage, and energy bill minimization. A new algorithm for programming the EMC to schedule household load is developed in [28]. The EMC schedules home appliances in such a manner that the load is shifted to the battery during peak hours. The work [29] proposed a hybrid optimization technique of GA and MILP for economic dispatch. The authors of [30] incorporate a mutation operator with ACO algorithm to resolve the problem trapping at local optima with primary DSM objectives such as PAR, and cost minimization. The authors in [31] scheduled the home appliances to mitigate PAR and minimize the delay time of appliances. However, the Carbon emission is not taken into account in their study. The authors of [32] implemented the Firefly Algorithm (FA) for energy management under the pricing schemes such as Real-Time Price (RTP) and Critical Peak Price (CPP). However, user comfort is compromised. The Grey Wolf Accretive Satisfaction Algorithm (GWASA) to solve the residential demand-side management problem with the lowest cost and highest ratio of satisfaction in [33]. The [34] used the Candidate Solution Updation Algorithm (CSUA) for reducing PAR and consumer delay time by increasing user comfort level. The authors of this paper considered uncertainties in loads and ensured optimal scheduling to facilitate residents. The authors presented an intelligent energy management principles and technology issues for smart grid applications to help the Distributed Electric System (DES). The authors in [35] conducted a comprehensive analysis of IoT-based energy management in smart communities. Following that, the foundation and software model for an IoT-based system at the network's edge is presented. The authors developed optimum power scheduling technique using RTP and Inclining Block Rate (IBR) tariff to minimize electricity costs, reduce the PAR, and minimize user discomfort. The authors in [36] proposed hierarchical architecture using cloud computing and edge computing to a distributed architecture which provides autonomous strategic decisions with agent-based intelligence for massive information. In households and grids, large-scale information gathering, communications, processing, and control are performed through agents for cooperative energy management. The results of the experiments show that the agent-based solution is promising in cooperative energy management. In [37], the authors developed a game-theoretical model to schedule entire electricity consumption scheduling for efficient power consumption planning and DSM. The [38] proposed load schedling and distributed storage approach to improve user satisfaction and minimize customer energy costs. In [39], an optimization-based energy management structure is developed to schedule consumer energy consumption pattern using RTP signals under utility, PV, and ESSs. The purpose is to reduce energy bills, carbon emissions, and peak power consumption while mitigating pricing rebound peak generation. The authors proposed a multi-domain communication network with federation concept in [40]. This model introduced how IEC 61850 and the extensible Message Presence Protocol (XMPP) may be used to provide a common communication framework for Virtual Power Plants (VPPs) management in smart grids. A privacy-preserving technique is introduced. The nodes use accurate data for estimation and broadcasting the noisy version in [41]. The authors show that the proposed algorithm can protect privacy and retain the final solution's convergence and optimality. Extensive simulations indicate that their proposed strategies are effective. The authors used a GA-, game theory-, and fuzzy logic-based framework that seeks to maximize profit by choosing the optimum alternative and forecasting future energy demands [42]. The authors implemented a Cuckoo Search Algorithm (CSA) to study the impact Battery Energy Storage (BES) on power system operation [43]. A gametheoretic (Stackelberg) model is introduced in [44] to examine coordination of generators with microgrids. A novel technique with Artificial Neural Networks (ANN) is developed for expressing and conveying the energy flexibility of distributed energy resources for efficient energy management [45]. In [46], the authors proposed a scheduling technique based on the markov decision process for energy management in a smart grid . This work aims to lower a customer's energy expenditure. The authors in [47] presented a method for regulating the active and reactive power flow in an islanded renewable generating system's Point of Common Connection (PCC). In [48], the authors employed optimum DR technique to maintain balance between supply and demand. The DR program engaged the Plug in Hybrid EVs (PHEVs) at parking stations as distributed energy storage and source to participate in DSM.
The related works discussed above are summarized in Table 1. All the methods discussed above are capable and effective in energy management. However, the researchers did not all use key features such as advanced metering infrastructure, forecasting, and bidirectional communication of the smart grid. Furthermore, mostly researchers assumed consumers behavior and RESs profile. Some authors focused on electricity cost minimization, others catered for PAR alleviation, a few handled both electricity cost and PAR minimization, while some authors considered user comfort maximization. However, the objectives such as electricity cost, carbon emission, PAR, and user comfort are not handled simultaneously by any authors in the literature. Thus, it is concluded from the above literature that electricity cost, carbon emission, PAR, and user comfort are energy management objectives, where carbon emission and PAR are utility objectives which are directly linked to customer objectives such as energy cost and user comfort. The utility and customer objectives are contradictory in nature and challenging to handle simultaneously.

References Sources
Storage Objective(s) Proposed Algorithm [14] RES + CG ESS + MGT Reducing PAR, minimizing cost, maximizing user comfort MILP [15] RES + CG ESS Minimizing cost and PAR Game-theory framework [16] RES + CG ESS Reducing electricity cost MILP [17] RES + CG ESS Reducing electricity cost MILP [18] RES + CG ESS Short term energy demands PGCC and MILP [19] RES + CG ESS Issues faced by prosumer PEMS and MILP [20] RES + CG ESS Saving consumer cost MILP [21] RES + CG ESS Electricity price varying MPC [22] RES + CG ESS Minimizing electricity cost PI and ANFIS [23] RES + CG ESS Minimizing electricity cost DMPC [24] RES + CG ESS Reducing electricity cost MPC [25] RES + CG ESS Reducing green house gases emissions MPC [26] RES + CG ESS Energy-saving and gain MPC [27] RES + CG ESS Carbon emission, energy consumption and reducing electricity cost GA [28] RES + CG ESS Cost minimization, maximize comfort level Control algorithm [29] RES + CG ESS Minimizing cost and PAR and economic dispatch GA and MILP [30] RES + CG ESS Minimizing PAR and cost ACO algorithm [31] Reducing PAR cost, and consumer delay time GmEDE [32] RES + CG ESS Minimizing electricity cost FA [33] RES + CG ESS Minimize cost and high level of user satisfaction GWASA [34] RES + CG ESS Reducing PAR and increase user comfort level CSUA [49] RES + CG ESS Minimizing cost and PAR GA, GWO, mEDE and GmGWO [50] RES + CG ESS Issues of EVs integration smart grid DES [35] RES + CG ESS Cost minimization IoT-based system [51] RES + CG ESS Minimizing cost and reducing PAR Aquifer Thermal Energy Storage (ATES) [36] RES + CG ESS Reducing electricity cost Hierarchical architecture [37] RES + CG ESS TCLs electricity consumption scheduling and minimizing RES fluctuation Game-Theoretic Demand Side Management [52] RES + CG ESS + BES Minimizing cost and PAR GA and PSO and ACO [38] RES + CG ESS Minimizing cost and User comfort level Distributed storage strategy [39] RES + CG ESS Minimizing cost and PAR HGACO [40] RES + CG ESS VPPM XMPP based IEC 61850 communication [41] RES + CG ESS Accurate data for state changing Privacy-preserving technique [42] RES + CG ESS Predicting future energy demands using GA Game-theory based fuzzy logic [43] RES + CG ESS BES on the functioning of power systems CSA [44] RES + CG ESS Maximizing their payoffs Stackelberg game theoretic framework [45] RES + CG ESS Energy flexibility of distributed energy resources ANN [46] RES + CG ESS Lowering Consumer's electricity cost MDP [47] RES + CG ESS Reactive islanded power flow PCC [48] RES + CG ESS Energy Balance and flexible loads Multilayer individual-based optimization algorithm Thus, an optimization technique is needed that considers user priority, DR program, and comfort constraints to cater for uncertainties in load and renewable generation for efficient energy utilization, energy cost reduction, PAR alleviation, carbon emission mitigation, and end-user satisfaction, to satisfy both utility providers and consumers at the same time. In this regard, an innovative framework composed of residential smart homes and a grid-connected smart microgrid is proposed. Furthermore, an efficient energy management scheme based on the ACO algorithm is developed for the proposed framework to systematically schedule load and EV's charging/discharging connected in a smart microgrid.

Framework of Efficient Energy Management System
Efficient energy management framework is presented in this section, followed by a description of the day-ahead energy generation prediction model. The complete implementation diagram of the proposed model is depicted in Figure 1, which is discussed in detail in subsequent sections.

Start
IniƟalizing all parameters which relates funcƟon of Ɵme and also maximum iteraƟon Ɵmes, the number of ants. z=0 (

System Model
The proposed system model is composed of a residential smart home equipped with smart meter and smart appliances, and a smart microgrid comprising WT, PV panels, electrolyzer, and hydrogen tank. The proposed system model is depicted in Figure 2. However, residential consumers load and electricity generation of a microgrid is stochastic and uncertain. Thus, an ANN-mEDE-based prediction model is developed for efficient energy management. An efficient EMC based on ACO algorithm (whose control parameters are listed in Table 2) is installed to systematically schedule load and EVs charging/discharging connected to a smart microgrid according to RTP signal. In our proposed work, the simulation time T is assumed to be 1 day, which is split into sub-timeslots of equal duration denoted by t(1h). The detailed description of each component of the proposed system model is as follows.

Energy Generation Prediction Model
This section describes the prediction model to predict solar irradiation and wind speed for effective generation estimation. In this regard, a framework of ANN-mEDE is developed to predict solar irradiation and wind speed for effective estimation of generation. The proposed prediction model is composed of three parts: (i) feature selector, (ii) forecaster, and (iii) optimizer. Feature selector phase of the prediction model based on mutual information technique uses time-series solar irradiation and wind speed as input. The mutual information technique rank the inputs and passed the ranked inputs to redundancy and irrelevancy filters for the removal of irrelevant and redundant features. Then, the selected inputs are split into training and testing datasamples.
The forecaster phase is based on an artificial neural network (ANN), which uses training and testing sets to forecast solar irradiation and wind speed for a day-ahead time horizon. The ANN is a multilayer feed-forward network, where each succeeding layer gets input from the preceding layers. In other words, the outputs of one layer's nodes are used as inputs in the next layer. A weighted linear combination is used to combine the inputs, which are changed by a nonlinear function [53] to generate output.
The ANN has three layers layout having input, hidden, and output layers, where Artificial Neurons (ANs) in each layer are exploited by sigmoidal activation function [54], which is shown in Equation (1) as follows.
The input signal is S with attributes (as discussed in the first module). The parameter β is for steepness control of the activation function and b indicates the bias value. As discussed above, the developed prediction model is enabled via training to learn and accurately estimate future energy generation. In the literature, learning mechanisms such as unsupervised, supervised, and re-enforcement learning exist. The developed forecasting framework learns from time series analysis with the supervised learning approach, which employs multivariate autoregressive rules due to high convergence than benchmark learning rules [55]. Solar irradiation and wind speed prediction model is illustrated in Figure 3. The RESs three-year weather data is adopted from [56]. The acquired data is divided into training and testing sets of 80% and 20%, respectively, as per the mechanism available [57][58][59].
The training set trains the forecasting framework to predict future values, and testing set validates the forecasting framework to show the accuracy of the obtained predicted results compared to the ground-truth observations. Mean absolute percentage error (MAPE) is a validation metric (to illustrate the relationship between ANN predicted output and observed values), which is formulated as follows in Equation (2) [54].
Where p actual (i, j) denotes the actual and p f orecast (i, j) represents forecasted solar irradiation and wind speed. m denotes number of days under observation. The control parameters are tuned using Levenburg Marquart algorithm until the error is minimized. The forecasted values (solar irradiation and wind speed) by ANN forecaster is fed to optimizer phase of the prediction model for further error minimization.
In the optimizer phase, the error is calculated between estimated and observed value, and this error is further minimized with the use of the mEDE algorithm in the optimizer phase. The meta-heuristic algorithms such as GA, PSO, FA, DE and GWO are widely used in prediction problems. The DE among these algorithms is selected due to its better performance in the aspects of fast converging speed, computational efficiency, and avoidance of premature convergence while seeking a global optimal solution. This better performance of DE is due to the different vector-based mechanism, which expands its search space [60]. On this note, the authors of [61][62][63][64] used DE and GA techniques, respectively; with this as motivation, we developed modified enhanced DE to optimize control parameters of the prediction model for returning accurate estimation without trapping into local optima and avoiding premature convergence. The energy estimations returned from the optimizer phase are more accurate and utilized for efficient energy management.

Mathematical Modeling
This section presents the mathematical modeling of a smart microgrid equipped with controllable appliances, PV panels, WT, electrolyzer, hydrogen tank, EVs, and ESS.

Modeling of Appliances Operating within Smart Home
This section presents explanation and modeling modeling of appliances operating within smart home. Each consumer is in contact with smart appliances. Moreover, each appliance is scheduled according to consumer demand. These appliances are further categorized into three categories: (i) Electrically Controllable-Appliances (ECA), (ii) Thermostatically Controllable-Appliances (TCA), and (iii) Optically Controllable-Appliances (OCA). Each category will be discussed in detail as follows.

Scheduling of ECA
An adaptive approach based on RTP signal for ECA scheduling such as PHEVs is proposed. The EMC schedules ECA as soon as it receives RTP signal from the utility. Consumers typically schedule smart appliances within the assigned time interval to avoid high payment due to operation in peak price hours. Furthermore, the ECA parameters such as the time interval in between the Earliest Starting Time (EST) and Latest Finishing Time (LFT), and Length of Operation Time (LOT) are adjusted using In-Home Display (IHD) and the adjusted parameters will be communicated to EMC via Home Gate (HG). These parameters are adopted from [65] and listed in Table 3. Table 3. Appliances Classification.

Category Appliance EST (h) LFT (h) LOT (h) Power (kw)
Electrically Controllable Appliances The appliance consumption cycle is started using the starting probability function, which is defined as P step in Equation (3): where A represents an ECA appliance, h represents the hour of the day, d represents the day of the week, W represents the week of the year, and δ represents the computing time step (second or minute), σ is the standard deviation for P social which represents the social random factor. Moreover, seasonal changes are customized by P season , P hour the probability hourly factor, P step stands for scaling factor, which scales the probabilities in consideration with δ. P start is described for each time interval δ it takes a value between 0 and 1. Further detailed elaboration is given in [65].

Scheduling of TCA
TCA may be electrical or thermal equipment such as an air conditioner or a water heater, which can be scheduled using the desired temperature and RTP signal. The air conditioner, refrigerator, heater, and freezer temperatures are denoted by T ac t , T f ridge t , T heater t , and T f reezer t , respectively, presented in Equations (4)-(7) which should be adjusted by consumers as per their specified temperature to avoid user-frustration. These circumstances can be stated as follows: where T ac min , T are air conditioner, fridge, heater and freezer upper bound, respectively. These appropriate temperatures may differ from one household to the next, since they are determined by each individual consumer to ensure user comfort. Further detailed elaboration can be found in [65].

Scheduling of OCA
The OCA mostly includes lighting loads, which are scheduled according to illumination. The lighting load is modeled using illumination level index, which is based on the activity probability, which indicates the house occupancy in the lighting load calculation. The following is how the illumination of a room (a) in the house is expressed in Equation (8).
A detailed elaboration is available in [65].

Microgrid
The microgrid considered in this work is equipped with controllable appliances, PV panels, WT, electrolyzer, hydrogen tank, EVs, and ESS for electricity generation. The net energy generated from the sources equipped with microgrid is m M in time interval t T is presented in Equation (9) as follows.
As the microgrid is equipped with RESs which are intermittent in nature, thus, the ANN-mEDE prediction model is implemented to predict solar irradiation and wind speed for next-day timeslots T for accurate future electricity generation estimation. The detailed explanation of generating sources equipped with microgrid is presented as follows.

Wind Turbine
The WT is entirely dependent on the wind speed for electricity generation, which is mathematically modeled in Equation (11) as follows.
where P wt represents WT electricity generation at timeslot t, A is the area swept by turbine blades through which WT generates power, V t wt denotes wind speed and air density is ρ.
The electricity generation from WT is directly proportinal to wind speed, i.e., the higher the wind speed, the higher the generation, and vice versa, as presented in Equation (11). The WT electricity generation is subjected to specified constraints [66], which are defined in Equations (12)- (14).

PV Panels
PV panels generates electricity from the sunlight, which is mathematically modeled in Equation (15) as follows [65].
where P t pv shows amount of electricity produced per hour from PV panels. The symbols A pv and η pv show area and efficiency of PV panel, respectively. Moreover, the Temp(t) and Irr(t) indicate amount of solar irradiation and the outside temperature at timeslot t.

Electrolyzer
An enhanced electrolyzer has been developed in our proposed study. In the electrolyzer model, electrochemical processes are employed. Furthermore, the maximum temperature of 100 • C was taken into account. An electrolyzer cell's electrode dynamics can be approximated using an empirical voltage relationship. Several electrolyzer empirical models have been proposed [67][68][69][70].
In addition, in order to model the temperature dependency of an over voltages, Equation (16) can be altered.

Hydrogen Tank
As this Bennedict Webb Rubin (BWR) equation comprises of eight parameters, and is more exact than that of three-parameter equations, particularly at temperatures above critical and pressures not exceeding extremely high, as indicated in Equation (17) [71].
where ρ represents gas density which relates to compressibility factor by (18): (18) where as, p is represented in atm, T is in kelvin (k), ρ is in mol/L, R = 0.08205 atm L/mol K. Moreover, the remaining parameters are as follows:

Micro-Gas Turbine
MGT is a generator used for electricity generation with a generation capacity range of 15-300 (kW). It is usually preferred due to its ease of installation and maintenance [72]. In this work, the MGT is employed as a backup and shiftable generating source, and operates as per the direction and requirement of users. Its generation is cheaper and environment friendly compared to diesel generators, and significantly contributes to carbon emission minimization [29]. On/off are the two operation statuses; it produces constant energy of 2 kW in on status while in off status, its generation is 0 kW [13].

Energy Storage System
ESSs includes static storage and mobile storage systems that are equipped with RES in the microgrid to store energy during on-peak hours (act as a load) and discharge energy to load in low price hours (act as a source). Complete discussion is presented below.

Static Energy Storage System: BES
The smart home considered in this work is equipped with BES with a storage capacity of 3 kWh, the same as is discussed in [14,73]. The BES is subjected to various constraints such as ESS min and ESS max , which represent minimum and maximum charge limit, respectively. Every BES has a predefined discharging limit, namely lower discharging limit, which is set at 20%, the same as is used in [74,75]. The energy stored in BES is mathematically modeled in Equation (19).
subjected to ES(t) ch ≤ ES max (20) ESS(t) ch < ESS upl (22) where SE shows stored energy at timeslot t in BES measured in Ah, η ESS is the efficiency of BES, ES ch (t) and ES dis (t) represent charging and discharging status at timeslot t, respectively. Moreover, the charging/discharging and idle status of BES is mathematically modeled in Equation (23) as follows.
When the status of BES is equal to 1, the battery is charging from RES and acts as a load. On the other hand, when the status of BES is equal to −1, the battery is in discharging mode and acts as a source; otherwise, it will be in idle mode.

Mobile Energy Storage System: EVs
EVs are employed as mobile energy storage systems as well as being used for driving purposes. The main objective is to mitigate fluctuations accompanied by RES and minimize energy cost. The EVs energy utilization for arrival and departure usage mode is mathematically modeled in Equation (48) as follows [14]. (24) where, in Equation (24), t e a represents EVs arrival time and t e d denotes EVs departure time. The symbols ψ e (t) and α e (t) denote charging/discharging in Ah and status of EV at timeslot t, respectively. When α e = 1 EV is in charging mode, α e = −1 EV is in discharging mode, and α e = 0 EV is in idle mode.

Problem Formulation
In energy management, the main objectives are energy cost, PAR, carbon emission, and user discomfort minimization to facilitate both end-users and utility. The energy management objectives can be achieved by actively engaging consumers/end-users in distributed generation and DR programs. In this work, end-users are engaged in both distributed generation and DR programs to obtain the energy management objectives. On this note, the EMC based on the ACO algorithm is employed, which receives a DR signal (RTP) and broadcasts it to consumers ahead of time. In response, consumers send their electricity consumption pattern to the EMC based on the ACO algorithm, whose control parameters are listed in Table 2. The EMC schedules power usage of consumers and charging/discharging of EVs and BES to manage the electricity consumption pattern of consumers in such a manner that energy cost is reduced, PAR is alleviated, carbon emission is mitigated, and user discomfort is minimized. Thus, the proposed objective function is modeled as optimization function to minimize the above-discussed objectives. Each optimization objective will be individually mathematically formulated following the whole energy management problem formulation.

Energy Cost
Energy cost is a payment made by consumers to utility providers for the electricity consumed for a specific period of time. The energy cost is formulated with the RTP signal offered by the utility provider. In 2009, FERC reported that consumers who implemented DR programs for power usage scheduling achieved 65% monetary benefit in aspects of cost reduction. The energy cost payment to the utility providers for energy consumption under the RTP signal without considering the microgrid is formulated in Equation (25).
where Γ ECA (t), Γ TCA (t), and Γ OCA (t) are electricity demand of ECA, TCA and OCA, respectively. Moreover, the total energy cost charged per day is formulated in Equation (26) as follows.
The energy imported per hour after considering the microgrid equipped with RES, BES, EV, and MGT is formulated in Equation (27) as follows.
Equation (28) shows that if Φ(t) > 0 the electricity is imported and if Φ(t) = 0, the energy is not imported. The total energy imported per day is formulated in Equation (29) as follows.
The consumers hourly and daily energy cost after considering the microgrid is formulated in Equations (30) and (31), respectively, as follows.
where δ(t) is the per hour energy cost and δ(T) is the total energy cost per day. The symbol Φ(t) represents imported electricity per hour and EP(t) is RTP signal.

PAR
PAR is a ratio of peak electricity consumption to average electricity consumption. The PAR is important for EUCs and users because it smooths out the load curve for utility providers, which stops operation of peak power plants during peak hours and thus reduces consumers energy cost. In this work, utility providers stimulate users to participate in DR either by load and EVs charging/discharging scheduling, and to install the EMC, both of which significantly contribute to PAR alleviation. The PAR is mathematically formulated in Equation (32) as follows.

User Comfort
User comfort is measured in various aspects such as waiting time, energy consumption, temperature, sound, illumination, and demographic energy demand patron of consumers. This study measures user discomfort in aspects of delay, i.e., how much of a delay a user confronts after scheduling. Furthermore, a tradeoff exists between energy bill and user discomfort; the users who tolerate more delay would be charged a lower energy cost and those who are not delay-tolerant would be charged a higher energy cost. The user comfort is measured in aspects of delay/waiting time, which is mathematically formulated in Equation (33).
where w a is the waiting time that each appliance may face after scheduling, T o,unsch a,t shows status of an appliance before scheduling, T o,sch a,t denotes status of an appliances after scheduling, and T lo a represents the total LOT of an appliance. The EMC based on the ACO algorithm schedules appliances in response to the RTP signal and consumer priority. An appliance that can tolerate maximum delay/waiting time is formulated in Equation (34) as follows.
where w d a represents maximum waiting time/delay an appliance faces after scheduling and T t a denotes the total time interval of appliances. User frustration increases with the increase in w d a and hence their comfort is compromised. The user discomfort is at its peak when w a = w d a , and this represents the worst case, which never happens. Percentage user discomfort is mathematically modeled in Equation (35).

Carbon Emission
Carbon emission is defined as the release of carbon dioxide in atmosphere while generating and using electricity in the energy sector. In this work, distributed generation and MGT are included in the microgrid instead of fossil fuels and diesel generators, while load and charging/discharging of EVs are scheduled, which reduces carbon emissions and ensures a cleaner and greener environment. The carbon emission is mathematically formulated in Equation (36) as follows.
The term Υ represents carbon emission which is measured in pounds, where mean(EP(t)) denotes mean electricity price, ε indicates price per kWh, ς is the electricity emission factor, and is the hour in the day.

Objective Function
Now, the overall problem is modeled as optimization problem to achieve our desired objectives: minimum energy cost, carbon emission, PAR, and user discomfort with load and charging/discharging scheduling, which is expressed is in Equation (37) as follows.
Subjected to: EV e min ≤ ρEV e a + EV e ≤ EV e max (48) The symbols used in the above equations are defined in Section 3 and presented in Nomenclature table.

Analysis of Simulation Results
Analysis of simulation results are discussed in this section. The extensive simulations are carried out in a MATLAB environment installed in the computer system with Intel Core i5 2.4 GHz processor, 8 GB RAM, and Windows 10 operating system, in order to show optimal operation and charging/discharging scheduling of EVs. This study uses four performance metrics including energy cost, PAR, carbon emission, and waiting time/delay for performance evaluation of the proposed model in comparison with existing models. The proposed system model was developed for a residential smart home with three types of load: ECA, TCA, and OCA, which communicate with an EMC based on a ACO algorithm via the Internet, and the EMC schedule operation of appliances and charging/discharging of EVs per the RTP tariff received from the utility provider. The appliance description is discussed in Section 3 and their parameters are listed in Table 3. Furthermore, we developed a forecasting framework for solar irradiation and wind speed to accurately estimate electricity generation for efficient energy management. Simulations are conducted for cases: (I) energy management without a microgrid, (II) energy management with a microgrid for a 24 h time horizon. The detailed discussion is as follows.

Energy Management without Microgrid
This section presents the results and discussions of scenario I, where microgrid is not considered.
An RTP from Figure 4, it is obvious that the proposed scheme schedules the load during off-peak hours. When the proposed technique is not implemented, meanwhile, the maximum amount of energy is purchased during peak hours. In this figure, the hourly cost is also shown.
The electricity consumption profile of appliances like ECA, TCA, and OCA within home in presence of RTP tariff received from utility with and without proposed approach is illustrated in Figure 4 and their 24 h status is listed in Table 4. It is obvious that the proposed scheme schedules operation of most appliances during low and mid price hours considering the priority of users to ensure both objectives: energy cost and user discomfort minimization. In contrast, the MILP schedules the operation of most appliances during low price hours cause user discomfort and rebound peak creation. However, the MILP is better than the case without scheduling. The energy cost hourly pattern of this scenario is depicted in Figure 5. It is observed in the energy cost profile that our proposed scheme optimally schedules the operation of smart home appliances keeping in view both user priority and energy cost constraint, and hence have little bit more energy cost during peak hours. On the other hand, with MILP-based schedules, consumers pay minimum cost over our proposed case without scheduling because user priority constraints are ignored. Table 4. Operation schedule of smart home appliances with our proposed scheme.   Figure 6 illustrates the consumer's daily energy cost with and without using the proposed scheme. It is clearly seen in the Figure that our proposed scheme reduces energy cost significantly compared to without scheduling scheme and MILP based scheme. The solid reason for this performance is that the proposed scheme considers users priority and cost constraints, and minimizes both energy cost and user discomfort. In addition, it also avoids rebound peaks to ensure stable and reliable power grid operation. The PAR is illustrated in Figure 7 for existing and proposed schemes. The proposed scheme minimized the PAR to 40%, which is lower as compared to MILP and the case without scheduling.

Energy Management with a Microgrid
Simulations are conducted to evaluate the proposed scheme performance with and W/O microgrid in the proposed system model. microgrid is equipped with PV panels, WT, electrolyzer, hydrogen tank. The RES equipped with a microgrid are intermittent; therefore, the BES and EVs in the proposed microgrid are also included. The electricity is generated from sources such as PV panels, WT, electrolyzers, and hydrogen tanks depicted in Figure 8. It is visualized in figure that the PV generation is high during day time and lower at night time. This behavior is due to the well-known fact that the solar irradiation is high during daytime and lower during the night. The electricity generation from WT entirely depends on wind speed, i.e., electricity generation is maximum when wind speed is high and below the cut-out speed, and vice versa. Thus, we forecast wind speed to accurately estimate electricity generation from wind. Further, to ensure the accuracy of the prediction model, MAPE and NRMSE metrics are used, which are shown in Figure 9 and Figure 10, respectively. It is clear from the above figures that observed and forecasted values of wind are closely related ensures accurate estimation of electricity generation.   Solar energy is generated from sunlight, and is a sustainable and environmentally favorable energy source. Light from the Sun reaches the planet, which supplies energy.
However, we require power every hour in the generation process. Energy is generated for commercial, industrial, and residential customers to serve their load. As a result, it is more efficient. As seen from Figure 11 the solar generation is high during the daytime due to high solar irradiance. Figure 11. PV electricity generation profile.
From Figure 12, it is clear that when the wind speed is high, the generation is likewise high, and vice versa. Wind energy is the primary source of RES in a microgrid that is optimized for balancing energy supply, demand, and storage to ensure efficient energy management. However, a comparison of expected and measured electrolyzer voltage and accompanying power indicates that the slight under-prediction of temperature has virtually no relevance from the perspective of energy system modeling. For instance, we examine the one-day simulation described in our proposed study. By mixing hydrogen and oxygen, a hydrogen tank generates electricity, heat, and water. Frequently, fuel cells and batteries are combined. Both of these devices convert the energy generated by a chemical reaction into electrical energy. The hydrogen fuel cell, on the other hand, will keep producing energy as long as fuel (hydrogen) is available. Figure 13 illustrates the net electricity demand and imported electricity for serving smart home loads. Figure 13 clearly demonstrates that our proposed scheme shifts the load via scheduling from high price hours to low price hours, and serves the net load from the microgrid. Furthermore, the proposed scheme acquires power from the external grid during the hours when power rates are low. This figure also depicts the RES curve, which ensures that RES are serving the whole day to satisfy the user's electricity demand. Net electricity demand, imported electricity from WT, and purchased electricity from the power grid considering with/without EVs discharging capabilites are illustrated in Figure 14. It is obvious from results that the proposed model minimizes the energy purchased from the power grid during high price hours, importing energy from WT and enabling the discharging mode of EVs to ensure reliable power supply to the load. In contrast, smart homes import more energy in cases when EVs are driving or empty because EVs act as mobile storage.
The mobile storage EVs charging/discharging and electricity generation of the microgrid, including all sources, is depicted in Figure 15. The figure clearly shows that EVs charging mode is enabled when the microgrid generation is maximum and EVs have lower energy, and discharging mode is enabled when microgrid generation is minimum or there is no other source of energy available. In the first hour, the battery is fully charged, in 10-15 h timeslots it is charging, and 2-3 and 16-21 timeslots, it is discharging.  The EVs and BES participate in the microgrid with RES to significantly contribute in energy cost and PAR minimization as shown in Figure 16. It is obvious from the results that users utilize electricity from BES or EVs rather than importing electricity from the power grid during situations when electricity demand is at peak or high price hours, or when generation from the microgrid is scarce. This behavior highly contributes to energy cost reduction and PAR alleviation. The MGT is employed instead of a diesel generator to reduce carbon emissions and lower peak load. MGT will only operate when the user demand exceeds a certain threshold value. From Figure 17 it is evident that MGT only functions during peak hours to fulfil customer demand, and so PAR is lowered. Analysis is conducted for 24 h operation of the microgrid system to evaluate carbon emissions. In the microgrid, the MGT used in place of diesel generator because a diesel generator releases a large carbon footprint with RES. Thus, our proposed scheme with the use of the microgrid significantly minimizes (up to 25%) carbon emission; this is shown in Figure 18.

Conclusions
This work presents efficient energy management scheme to schedule operation of appliances and charging/discharging of EVs in the presence of RTP signal under utility with and without a microgrid. A prediction model, ANN-mEDE, is developed for accurate electricity generation estimation of the microgrid to contribute to efficient energy management. Then, an ACO algorithm is developed for the proposed scheme to solve energy management problems via scheduling with and without microgrid scenarios. The aims and objectives of solving the energy management problem are maintaining a balance between demand and supply for reducing energy cost, PAR, carbon emission, and user discomfort to facilitate both parties, utility providers and end-users, at the same time. To endorse the developed model, simulations are conducted in comparison with the existing scheme based on MILP and cases without scheduling in with and without microgrid scenarios. The results depict that the proposed scheme reduced energy cost, carbon emission, and PAR by 35%, 25.01%, and 40.12% in scenario I; by 55.05%, 45.5%, and 42.4% in scenario II, respectively.

Conflicts of Interest:
The authors declare no conflict of interest.