**1. 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

**Citation:** Albogamy, F.R.; Hafeez, G.; Khan, I.; Khan, S.; Alkhammash, H.I.; Ali, F.; Rukh, G. Efficient Energy Optimization Day-Ahead Energy Forecasting in Smart Grid Considering Demand Response and Microgrids. *Sustainability* **2021**, *13*, 11429. https://doi.org/10.3390/ su132011429

Academic Editors: Sheraz Aslam, Herodotos Herodotou and Nouman Ashraf

Received: 4 October 2021 Accepted: 11 October 2021 Published: 16 October 2021

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

paradigms of distributed generation and smart grid have emerged for electricity generation and consumption. These paradigms are prominent in the electricity market around the world because they have low transmission losses and provide electricity intelligently with control to consumers. According to [1], the distributed generation definitely refers to microgrids, which is small-sized, near to consumers, and directly connected to the distribution system. Smart grids are power grids with advanced communication and control technologies between consumers and generating stations, delivering optimized power usage, clean energy at reduced cost, and improving the quality of energy and efficiency of the power grid. They also provide reductions in technical losses and greenhouse gas emissions, and solve the high carbon emissions problem, where 23% and 41% pollution emission is caused by transport sector, and energy sector, respectively, around the globe [3]. Thus, the conventional power gird is not able to meet future electricity demand due to dependence on limited and environment foe fossil fuels.

With microgrids, evolution dependence on fossil fuels is reduced, and high carbon emission problem is resolved. Furthermore, the microgrid can be connected with smart homes in modes like grid-connected and islanded. In islanded mode, microgrids and commercial grids couldnot initiate the purchase/sell mechanism of energy. On the other hand, in grid-connected mode, the microgrid purchases and sells electricity from/to the external power grid. In the recent past, a significant variety of forecasts have been employed. The selection of a forecasting model is typically dependent on the available data, the model network mechanism's aims, and the energy planning operation. In this paper, we examine renewable energy and power forecast models used as an energy planning tool in a critical and precise way, the application of these techniques for forecasting, their accuracy for geographical and temporal prediction, and their significance to policy and planning purposes are all explored. Machine learning models handling enormous data while also providing precise predictive analyses. By integrating various models and using ensemble methods, we may improve forecasting accuracy. Artificial neural networks, when utilised correctly, can help one make better decisions because they can extract and model previously unknown correlations and characteristics [4]. The microgrid includes renewable energy sources (RES) such as solar, wind etc., to generate electricity, contributing to pollution emission minimization. Furthermore, RES are intermittent in nature; thus, one cannot rely on them. Therefore, ESSs and EVs are used with RES to solve this problem.

One of the problems to be catered within smart grid/smart home is energy management, whose purpose is to give greater control to the user's over their power usage to promote the efficient use of electricity, which is possible with the implementation of demand response (DR). The DR is classified in two classes, namely: direct DR program, in which the electric utility company (EUC) operator disconnects or interrupts the load as per an interruption contract signed with the consumer; indirect DR program, where the consumer changes/adapts their demand in response to the offered pricing signaled by the EUC operator [5]. The latter DR program is the focus of this work.

The indirect DR program plays a vital role in cost efficient and reliable power system operations [6]. In [7], users reduced cost and improve comfort level via scheduling smart home appliances using indirect DR program. Similarly, the DR program is used to schedule multiple homes' loads with the same living patterns in [8]. However, the assumptions made by the authors seem impractical because, usually, multiple homes do not have the same devices with the same operation time and power rating. A novel energy management scheme can create optimal schedule of appliances power usage, which illustrates the same profile as the microgrid generated power. The users reduce electricity cost and import a minute amount of energy from the commercial power grid by adopting the optimal schedule. In this manner, efficient energy management ensures stable and reliable microgrid operation. In [9], EMC is introduced, which schedules the power usage pattern of a single home to alleviate peak demand. This work considered RES and day-ahead weather information to ensure energy cost minimization and an energy efficient operation. The paper [10] proposed a strategy for cost minimization considering weather parameters. 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.


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.

#### **2. 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.

#### *2.1. 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.

#### *2.2. 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.

#### *2.3. 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.

**Table 1.** A detailed analysis of the most relevant study in terms of sources, storage, objectives, and proposed algorithms. Abbreviations used in the Table are; RESs = Renewable Energy Sources, CG = Commercial Grid, BES = Battery Energy Storage, ESS = Energy Storage System, and MGT = Micro Gas Turbine.


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.

#### **3. 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.

**Figure 1.** Proposed scheme implementation flow chart for efficient energy management

#### *3.1. 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*(1*h*). The detailed description of each component of the proposed system model is as follows.


**Figure 2.** Proposed system model schematic diagram

### *3.2. 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.

$$f(\mathcal{S}, b) = \frac{1}{1 + e^{-\beta(\mathcal{S} - b)}}\tag{1}$$

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–59].

$$MAPE(i) = \frac{1}{n} \sum\_{j=1}^{m} \frac{\left| p^{actual}(i, j) - p^{forecast}(i, j) \right|}{p^{actual}(i, j)} \tag{2}$$

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–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.

**Figure 3.** Solar irradiance and wind speed prediction model for estimation of electricity

#### **4. 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.

#### *4.1. 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.

#### 4.1.1. 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.

The appliance consumption cycle is started using the starting probability function, which is defined as *Pstep* in Equation (3):

$$P\_{\rm start}(A, \mathcal{W}, \delta, \sigma\_{\rm flat}, h, d) = P\_{\rm sensor}(A, \mathcal{W}) P\_{\rm hour}(A, h, d) P\_{\rm step}(\delta) P\_{\rm social}(\sigma\_{\rm flat}) \tag{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 *Psocial* which represents the social random factor. Moreover, seasonal changes are customized by *Pseason*, *Phour* the probability hourly factor, *Pstep* stands for scaling factor, which scales the probabilities in consideration with *δ*. *Pstart* is described for each time interval *δ* it takes a value between 0 and 1. Further detailed elaboration is given in [65].

#### 4.1.2. 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:

$$T\_{\rm min}^{\rm ac} \le T\_t^{\rm ac} \le T\_{\rm max}^{\rm ac} \tag{4}$$

$$T\_{\text{min}}^{firdge} \le T\_t^{firdge} \le T\_{\text{max}}^{firdge} \tag{5}$$

$$T\_{\text{min}}^{\text{heater}} \le T\_t^{\text{heater}} \le T\_{\text{max}}^{\text{heater}} \tag{6}$$

$$T\_{\text{min}}^{freezer} \le T\_t^{freezer} \le T\_{\text{max}}^{freezer} \tag{7}$$

where *T ac* min, *T f ridge* min , *T heater* min *and Tf reezer* min are air conditioner, fridge, heater and freezer lower bound, while *T ac* max, *T f ridge* max , *T heater* max *and Tf reezer* max 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].

#### 4.1.3. 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).

$$L\_t^a + L\_t^{OUT} \ge (1 + k\_l)L\_t^{a, \text{min}} \tag{8}$$

A detailed elaboration is available in [65].

#### *4.2. 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 e M* in time interval *t e T* is presented in Equation (9) as follows.

$$E(t) = \sum\_{m \in \mathcal{M}} \varepsilon m(t) \tag{9}$$

where *em* represents microgrid generation. Equation (10) calculates microgrid total electricity generation.

$$E(t) = \sum\_{t=1}^{T} \sum\_{m \in M} \varepsilon m(t) \tag{10}$$

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.

#### 4.2.1. Wind Turbine

The WT is entirely dependent on the wind speed for electricity generation, which is mathematically modeled in Equation (11) as follows.

$$P^{\rm wt}(t) = 1/2 \times \mathbb{C}\_p \times (\lambda) \times \rho \times A \times (V\_t^{\rm wt})^3 \tag{11}$$

where *P wt* represents WT electricity generation at timeslot *t*, *A* is the area swept by turbine blades through which WT generates power, *V<sup>t</sup> 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).

$$V^{\rm cut-in} \le V^{\rm wt}(t) \le V^{\rm cut-out} \tag{12}$$

$$0 = V^{wt}(t) \ge V^{cut-out}, \quad \forall \ t \text{ } \varepsilon \text{ } T \tag{13}$$

$$0 = V^{wt}(t) \le V^{cut-in}, \quad \forall \ t \text{ } \varepsilon \ T \tag{14}$$

#### 4.2.2. PV Panels

PV panels generates electricity from the sunlight, which is mathematically modeled in Equation (15) as follows [65].

$$P\_t^{pv} = \eta^{pv} \times A^{pv} \times Irr(t) \times (1 - 0.005 \times (Temp(t) - 25)) \tag{15}$$

where *P<sup>t</sup> 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*.

#### 4.2.3. 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–70].

$$
\mathcal{U}I = \mathcal{U}\_{rev} + \frac{r}{A}I + s\log(\frac{t}{A} + 1) \tag{16}
$$

In addition, in order to model the temperature dependency of an over voltages, Equation (16) can be altered.

#### 4.2.4. 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].

$$p = RT\rho + (B\_0RT - A\_0 - \frac{C\_0}{T^2})\rho^2 + (bRT - a)\rho^3 + aa\rho^6 + \frac{c\rho^3}{T^2} \ast \left[ (1 + \gamma\rho^2) \exp(-\gamma\rho^2) \right] \tag{17}$$

where *ρ* represents gas density which relates to compressibility factor by (18):

$$z = 1 + (B\_0 - \frac{A\_0}{RT} - \frac{c\_0}{RT^3})\rho + (b - \frac{a}{RT})\rho^2 + \frac{aa}{RT}\rho^5 + \frac{c\rho^2}{RT^3}[(1 + \gamma\rho^2)\exp(-\gamma\rho^2)] \tag{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:

*<sup>a</sup>* <sup>=</sup> <sup>−</sup>9.2211 × 10−<sup>3</sup> (L/mol)<sup>3</sup> atm; *A*<sup>0</sup> = 9.7319 × 10−<sup>2</sup> (L/mol)<sup>2</sup> atm; *b* = 1.7976 × 10−<sup>4</sup> (L/mol)<sup>2</sup> ; *B*<sup>0</sup> = 1.8041 × 10−<sup>2</sup> (L/mol); *<sup>c</sup>* <sup>=</sup> <sup>−</sup>2.4613 × 10<sup>2</sup> (L/mol)<sup>3</sup> K<sup>2</sup> atm; *C*<sup>0</sup> = 3.8914 × 10<sup>2</sup> (L/mol)<sup>2</sup> K atm; *<sup>α</sup>* <sup>=</sup> <sup>−</sup>3.4215 × 10−<sup>6</sup> [(L/mol)<sup>3</sup> ]; *γ* = 1.89 × 10−<sup>3</sup> [(L/mol)<sup>2</sup> ]

#### *4.3. 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].

#### *4.4. 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.

#### 4.4.1. 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 *ESSmin* and *ESSmax*, 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).

$$SE(t) = SE(t-1) + k \times \eta^{ESS} \times ES^{ch}(t) - k \times ES^{dis}(t) / \eta^{ESS} \tag{19}$$

subjected to

$$\left(ES(t)^{ch} \le ES\_{\text{max}}\right) \tag{20}$$

$$ES(t)^{\text{dis}} \ge ES\_{\text{min}} \tag{21}$$

$$ESS(t)^{ch} < ESS\_{upl} \tag{22}$$

where SE shows stored energy at timeslot *t* in BES measured in Ah, *η ESS* is the efficiency of BES, *ESch*(*t*) and *ESdis*(*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.

$$\alpha\_{\varepsilon}(t) = \begin{cases} 1 & \text{if } \operatorname{ESS} \quad \text{is } \operatorname{charging}\_{\prime} \\ -1 & \text{if } \operatorname{ESS} \quad \text{is } \operatorname{discharge}\_{\prime} \text{ing}\_{\prime} \\ 0 & \text{if } \operatorname{ESS} \quad \text{is } \operatorname{idle}\_{\prime} \end{cases} \tag{23}$$

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.

#### 4.4.2. 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].

$$EV\_{\varepsilon} = \sum\_{t=t\_d^{\varepsilon}}^{t\_d^{\varepsilon}} \left(\psi\_{\varepsilon}(t) \times a\_{\varepsilon}(t)\right) \tag{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 *α<sup>e</sup>* = 1 EV is in charging mode, *α<sup>e</sup>* = −1 EV is in discharging mode, and *α<sup>e</sup>* = 0 EV is in idle mode.

#### **5. 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.

#### *5.1. 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).

$$\mathcal{L}(t) = \left(\Gamma\_{ECA}(t) + \Gamma\_{TCA}(t) + \Gamma\_{OCA}(t)\right) \times EP(t) \tag{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.

$$\mathcal{L}(T) = \sum\_{t=1}^{T} (\Gamma\_{ECA}(t) + \Gamma\_{TCA}(t) + \Gamma\_{OCA}(t)) \times EP(t) \tag{26}$$

The energy imported per hour after considering the microgrid equipped with RES, BES, EV, and MGT is formulated in Equation (27) as follows.

$$\Phi(t) = \left( (\Gamma\_{\text{ECA}}(t) + \Gamma\_{\text{TCA}}(t) + \Gamma\_{\text{OCA}}(t)) - (E(t) + EV.\mathfrak{a}\_{\text{EV}(t)} + \text{ESS}.\mathfrak{a}\_{\text{ESS}(t)} + MGT.\mathfrak{a}\_{\text{MGT}(t)}) \right) \tag{27}$$

$$\Phi(t) = \begin{cases} \Phi(t) & \text{if } \Phi(t) > 0, \\ 0 & \text{otherwise} \end{cases} \tag{28}$$

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.

$$\Phi(T) = \sum\_{t=1}^{T} \Phi(t) \tag{29}$$

The consumers hourly and daily energy cost after considering the microgrid is formulated in Equations (30) and (31), respectively, as follows.

$$\delta(t) = \left(\Phi(t)EP(t)\right) \tag{30}$$

$$\delta(T) = \sum\_{t=1}^{T} \left( \Phi(t) \times EP(t) \right) \tag{31}$$

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.

*5.2. 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.

$$\mu = \frac{\max\left(\Gamma\_{ECA}(t) + \Gamma\_{TCA}(t) + \Gamma\_{OCA}(t) + ES^{ch}(t)\right)}{\Gamma\_{ECA}(t) + \Gamma\_{TCA}(t) + \Gamma\_{OCA}(t) + ES^{ch}(t)\Big/\_{4}}\tag{32}$$

where *µ* represents PAR.

#### *5.3. 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).

$$w\_a = \frac{\sum\_{t=1}^{T} \sum\_{a=1}^{n} \left| \left( T\_{a,t}^{o,unsch} - T\_{a,t}^{o,sch} \right) \right|}{T\_a^{lo}} \tag{33}$$

where *w<sup>a</sup>* 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.

$$w\_a^d = T\_a^t - T\_a^{lo} \tag{34}$$

where *w d a* represents maximum waiting time/delay an appliance faces after scheduling and *T t <sup>a</sup>* denotes the total time interval of appliances. User frustration increases with the increase in *w d <sup>a</sup>* and hence their comfort is compromised. The user discomfort is at its peak when *w<sup>a</sup>* = *w d a* , and this represents the worst case, which never happens. Percentage user discomfort is mathematically modeled in Equation (35).

$$D = \frac{w\_a}{w\_a^d} \times 100\tag{35}$$

#### *5.4. 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.

$$\Upsilon = \frac{mean(EP(t))}{\varepsilon \times \xi \times \Theta} \tag{36}$$

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.

#### *5.5. 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.

$$\text{minimize} \sum\_{t=1}^{T} \left( \begin{array}{c} (\Gamma\_{ECA}^{t} + \Gamma\_{TCA}^{t} + \Gamma\_{OCA}^{t}) - \\ (E^{t} + ESS^{t} + EV^{t} + MGT^{t}) \end{array} \right) \times \text{EP}^{t} \tag{37}$$

Subjected to:

$$E(t) = P^{pv}(t) + P^{wt}(t) + P^{hyd}(t) + P^{elec}(t),\tag{38}$$

$$
\begin{array}{l}
\Gamma^t\_{\text{ECA}} + \Gamma^t\_{\text{TCA}} + \Gamma^t\_{\text{OCA}} = E^t + ESS^t \\
+ EV^t + MGT^t + \Phi^t
\end{array}\tag{39}
$$

$$\sum\_{a=1}^{n} \eta = LOT(a),\tag{40}$$

$$\sum\_{a=1}^{n} \alpha \le \eta \le \beta,\tag{41}$$

$$\mathcal{U}\_{rev} = \frac{\Delta G}{zF} \tag{42}$$

$$z = \frac{pV\_m}{\mathbf{n}\tau} \tag{43}$$

$$z = \frac{r \cdot m}{RT} \tag{43}$$

$$\Phi\_t \le KI\_\prime \tag{44}$$

$$V^{\text{cut-in}} \le V(t)^{\text{wt}} \le V^{\text{cut-out}}, \qquad \forall \text{ t } \in T,\tag{45}$$

$$0 < Irr(t) < k\varepsilon,\qquad\qquad\forall\ t\ \varepsilon\ T,\tag{46}$$

$$0 < ESS\_{\text{min}} < ESS\_{\text{max}} \qquad \forall \, t \; \text{\; } T\_{\text{\;}} \tag{47}$$

$$EV\_{\rm min}^{\varepsilon} \le \rho EV\_{a}^{\varepsilon} + EV\_{\varepsilon} \le EV\_{\rm max}^{\varepsilon} \tag{48}$$

The symbols used in the above equations are defined in Section 3 and presented in Nomenclature table.

#### **6. 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.

#### *6.1. 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 4.** Energy consumption profile for energy management without microgrid scenario.

**Figure 5.** Energy cost profile without microgrid.

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.

66

**Figure 6.** Net Energy cost evaluation without microgrid scenario.

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.

**Figure 7.** Net PAR evaluation without scheduling scenario.

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.

**Figure 8.** Microgrid electricity generation profile.

**Figure 9.** Prediction model evaluation using NRMSE.

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.

**Figure 12.** Wind electricity generation profile.

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.

**Figure 13.** Hourly optimal demand and imported electricity.

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.

**Figure 14.** Electricity purchase with/without discharging EVs.

**Figure 15.** EVs charging and discharging behavior with mircogrid electricity generation.

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.

**Figure 16.** EVs and BES hourly share for serving load.

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.

**Figure 17.** Optimal demand and MGT contribution.

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.

**Figure 18.** Hourly carbon emissions.

#### **7. 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.

**Author Contributions:** Conceptualization, Data curation, Methodology, Resources, Validation, Writing—original draft, Writing—review & editing, F.R.A.; Conceptualization, Data curation, Methodology, Resources, Validation, Writing—original draft, Writing—review & editing, Formal analysis, Funding acquisition, Investigation, Project administration, Supervision, and Visualization, G.H.; Writing—review & editing, Formal analysis, Funding acquisition, Investigation, Project administration, Supervision, and Visualization, I.K.; Writing—review & editing, Formal analysis, Funding acquisition, Investigation, Visualization, S.K., Writing—review & editing, Formal analysis, Funding acquisition, Investigation, Visualization and Investigation, H.I.A.; Writing—review & editing, Formal analysis, Funding acquisition, Investigation, Visualization and Investigation, F.A. and G.R. All authors have read and agreed to the published version of the manuscript.

**Funding:** The article processing charge is supported by the Taif University Researchers Supporting Project Number (TURSP-2020/264), Taif University, Taif, Saudi Arabia.

**Acknowledgments:** The authors would like to acknowledge the support from Taif University Researchers Supporting Project Number (TURSP-2020/264), Taif University, Taif, Saudi Arabia.

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

### **Nomenclature**



#### **References**

