Towards Efficient Energy Management and Power Trading in a Residential Area via Integrating a Grid-Connected Microgrid

Demand side management (DSM) is one of the most challenging areas in smart grids, which provides multiple opportunities for residents to minimize electricity cost. In this work, we propose a DSM scheme for electricity expenses and peak to average ratio (PAR) reduction using two well-known heuristic approaches: the cuckoo search algorithm (CSA) and strawberry algorithm (SA). In our proposed scheme, a smart home decides to buy or sell electricity from/to the commercial grid for minimizing electricity costs and PAR with earning maximization. It makes a decision on the basis of electricity prices, demand and generation from its own microgrid. The microgrid consists of a wind turbine and solar panel. Electricity generation from the solar panel and wind turbine is intermittent in nature. Therefore, an energy storage system (ESS) is also considered for stable and reliable power system operation. We test our proposed scheme on a set of different case studies. The simulation results affirm our proposed scheme in terms of electricity cost and PAR reduction with profit maximization. Furthermore, a comparative analysis is also performed to show the legitimacy and productiveness of CSA and SA.


Introduction
World increasing population, global warming, the rise in carbon emissions and increasing electricity demand create an alarming situation for electricity producing and distributing companies as well as for governments to take any strong action against these alarming situations.The electricity producing companies are detained from integrating renewable energy sources (RESs) to overcome global warming and carbon emissions [1].The present fossil fuel based electric grid is working on the centralized approach: only a few large electricity producing plants are operating at 50 Hz or more.High-power electricity plants are operating at very high voltage (i.e., 400 kV or more).Then, the produced electricity from large plants is distributed to the electricity consumers.A large number of supply lines supply the high voltage load to heavy industries and low voltage load to residential consumers and small-scale industries.
The power flow in the present power system is unidirectional due to the centralized approach.Electricity consumers are considered just passive users; they cannot play any role in the stability and reliability of the electric grid.According to [2], more than 65% of total electricity is wasted during generation, transmission and distribution of electricity.The basic reasons behind electricity wastage are that the present electricity system has unidirectional communication and a lack of monitoring technologies.The novel approach is distributed based on bidirectional communication.It provides the widely and higher distributed intelligence in electric power generation, distribution and flow of information.Furthermore, the novel approach provides the multiple opportunities for electricity consumers to manage their electricity consumption for bill reduction and reliable grid operation.
The novel approach is a smart grid and integration of cost-efficient RESs hold promise to tackle the above-discussed problems in the traditional electric grid.In the smart grid, electricity is generated via cheaper and efficient resources and then distributed to electricity consumers through smart transmission lines.Electricity prosumers are the consumers they can utilize as well as produce the electricity from their own local microgrid, which consists of multiple RESs, i.e., solar panel, wind turbine, hydro power plant, etc.They utilize electricity from their own generation and are also interconnected with the commercial grid.In case of less electricity generation, as compared to load demand, they purchase electricity from utilities or neighbors.If the electricity production from their own microgrid is more than the load demand, then the excess electricity is sold back to the commercial grid or stored in batteries for future use when electricity generation is low.The batteries may discharge only when electricity production from the microgrid is low or per unit electricity price is high.
At present, RESs generate few kilowatts (kW) or megawatts (mW) of electricity in residential areas and integration of RESs on a large-scale is widely diffused around the globe.Furthermore, electricity generation via RESs and integration of storage systems are enabling smart homes and small-scale industries to gain profit by selling excess electricity to the grid or neighbors.Moreover, end users may purchase energy when electricity tariffs are low and sell back electricity when prices are high.
In addition, approximately 10-30% electricity consumption can be saved through demand side management (DSM) [3].There are many dynamic pricing schemes (to calculate electricity consumption cost) for consumers' motivation to alleviate their electricity consumption in ON-peak hours.These pricing schemes include real-time pricing (RTP), time of use (ToU), critical peak pricing (CPP) and critical peak rebate (CPR) [4].Electricity consumers have the option to select the best electricity tariff according to their satisfaction.
In smart grids, two-way communication provides an opportunity to optimize consumption costs along with peak to average ratio (PAR) minimization.Due to the advent of a smart grid, a lot of studies have focused in regard to cost and PAR reduction via DSM [5][6][7][8].However, none of this work has included the capability to generate and store electricity for future use.The authors in [9] have proposed a DSM scheme by considering different types of electricity consumers.Optimum electricity consumption with maximum user comfort is determined in [10] within a smart home containing different types of smart appliances.They also investigate their proposed scheme on smart buildings, comprised of multiple smart homes with different living patterns (power rating and load demand).A cost efficient home energy management scheme has been proposed in [11].The authors of [11] also integrate the RESs to minimize the electricity cost and carbon emissions.Furthermore, the consumers are able to store excess electricity in batteries for future use; when electricity rates are high, stored electricity is consumed.The authors of [12] have proposed a new smart grid architecture for electricity consumers.They also integrate the RESs for electricity generation.According to their work, the consumers are able to consume, generate, store and sell excess electricity.The excess electricity is sold back to the electric grid for earnings maximization.Most of the recently proposed schemes used look at the problem from the grid or electricity consumer's perspective.
In this work, a DSM scheme has been proposed for electricity cost and PAR reduction via integrating the RESs and energy storage system (ESS) in a residential area.We consider a smart home that not only utilizes electricity from the commercial grid but is also capable of generating electricity from its own microgrid and storing electricity for future use.Furthermore, the smart home is independent from making autonomous decisions for electricity cost and PAR reduction with revenue maximization in each hour.Therefore, maximizing the revenue generated from power trading is also the objective of this work.A smart home makes decisions according to electricity tariffs.When prices are high, the home tries to reduce load demand and excess electricity is sold back to the commercial grid.The home purchases electricity in low price time slots while minimizing the PAR.
Furthermore, two different RTP schemes are considered for electricity cost calculation in terms of purchasing and selling electricity.At the end, a comparative analysis is performed to show the performance of the cuckoo search algorithm (CSA) and strawberry algorithm (SA).Our main contributions in this work are as follows: • Two heuristic approaches CSA and SA are implemented to schedule appliances for efficient power trading.

•
An analysis is performed to investigate the fact that CSA and SA are adaptable and capable of making autonomous decisions for effective scheduling of an appliance and optimal power trading with a commercial grid.

•
We enable a smart home to interact with the grid and make autonomous decisions for selling power to the grid for getting financial benefits.

•
In order to validate the effectiveness of CSA and SA, extensive simulations are performed in MATLAB (2017a) and the performance parameters are total cost and PAR along with earnings.

•
Simulation results show that our proposed scheme significantly reduces the electricity cost and PAR with earning maximization.
The remainder of the document is organized as follows: a literature review is presented in Section 2. Section 3 explains the problem statement and proposed system model.In Section 4, we explain our proposed scheme.Case studies are explained in Section 5 and simulation results are presented in Section 6.Finally, paper findings and future work are explained in Section 7.

Related Work
Electricity cost reduction and load equilibrium between demand and supply are the interesting and challenging research problems that have been tackled by researchers in the last few decades.Many DSM strategies have been presented in the last few years for electricity costs and PAR minimization while maximizing user comfort.Some of the existing work is presented below.
In [13], a home appliances scheduling scheme was proposed to reduce the total electricity cost and balance the load demand by mixed integer linear programming (MILP) in residential areas.The experimental results present that their proposed scheme rapidly obtains the desired targets, i.e., reduction in peak load and electricity cost.An integer linear programming (ILP) based strategy is proposed in [14].The basic objective of this study is to find equilibrium between electricity supply and demand in the residential area.Their proposed strategy efficiently shifts optimal operation time and optimal power for time-shiftable and power-shiftable appliances, respectively.Experimental results present that their proposed technique sharply archived the claimed objectives.
A MILP based model is presented in [15] for PAR and electricity cost reduction along with RESs integration.The simulation results validate this proposed model for electricity cost and PAR alleviation with efficient integration of RESs.Another optimization technique is presented by Mohamed et al.,in [16] using a genetic algorithm (GA).The objectives of this technique are energy cost reduction and load balancing between electricity supply and load demand.The authors of [17] further proposed a heuristic based technique using particle swarm optimization (PSO) and GA.The optimization problem is formulated through a multiple knapsack problem (MKP) along with three different pricing signals: ToU, RTP and CPP.Electricity bill and peak load reduction are the main objectives of this work.Experimental analysis shows the efficacy of proposed scheme using PSO and GA.Moreover, they also provide the comparison between GA and PSO, which shows that GA outperforms PSO.In [18], a dynamic programming (DP) based electricity cost reduction scheme was proposed.Electricity costs are reduced through scheduling of home appliances from ON-peak to OFF-peak time intervals.Furthermore, the game theory based approach is adopted to interact with the electricity consumers with extra electricity generation.In [19], the electricity cost optimization problem under the ToU environment is presented.Furthermore, they categorize the total load into three categories known as: interruptible load, shiftable load and weather based load.The authors of [20] considered three main objectives for the optimization problem, which are scheduling preference optimization, cost minimization and climatic comfort maximization.The demand response (DR) policy is presented in [21] and intends to obtain PAR reduction and electricity cost savings via scheduling of smart appliances according to hourly electricity prices.The home energy management system is presented in [22] using MILP to adjust the load demand among the PV panel, electric grid, ESS and electric vehicles.An electricity cost minimization scheme using GA was presented in [23], with RES and ESS integration.The ESS is used to balance the electricity supply and load demand.Experimental analysis shows the efficacy of their proposed scheme.
An intelligent home energy management scheme was presented in [24] for PAR and electricity cost minimization with the integration of RESs.In [11], an MILP based cost reduction and load balancing scheme is presented in a residential area.An MILP based home energy management system (HEMS) [12] considers electricity users as prosumers.They proposed HEMS for a single smart home and for a community of 39 prosumers.Each smart home has its own PV panel for electricity generation and is also connected with a commercial grid to meet the load demand.The prosumers store electricity in batteries when they have more generation than the requirements.However, they are not able to export electricity in high price hours for maximizing profit.In [13], a scheme is presented for cost minimization via integrating distributed energy sources.Moreover, each consumer has its own solar panel for electricity generation along with battery storage.Electricity consumers are able to sell or purchase electricity according to price signals.A RTP scheme is used in their work for electricity cost calculation.However, this work only considers non-interruptible appliances, which is not realistic for a smart home because there are appliances that can be interrupted, for instance, TV, etc.The authors of [25] studied the trading problem in smart grids.Electricity consumers are able to generate, purchase and sell electricity.However, they put their excessive amount of electricity on an auction market for bidding instead of selling to the main grid or single utility.Nevertheless, the ability of electricity consumers to generate electricity, store electricity and adjust their demand according to electricity tariffs, and selling excess electricity back to the electric grid simultaneously has not been considered in [11][12][13]25].Here, we propose a novel energy management scheme using CSA and SA to tackle the above-mentioned problems.

Proposed System Model
This work investigates a design of future smart grids that targets the reduction of electricity costs for consumers in a residential area, make electric grid stable and minimize the overall peak load during electric grid operation.The smart home equipped with multiple smart appliances with different power ratings and length of operational time (LOT), and this work is the extension of [26].
Furthermore, we consider an electric grid having the features of smart grid (bi-directional communication, efficient monitoring, etc.) with the single utility company.The single utility company provides electricity to the multiple consumers.Each consumer has multiple electricity consuming smart appliances and is also equipped with their own distributable energy generation system (EGS), i.e., microgrid.The microgrid consists of the wind turbine and solar panel.These distributed EGSs are intermittent in nature; therefore, to fulfill the load requirements of consumers, ESS is also installed, i.e., batteries.Electricity consumers meet electricity requirements by their own microgrid and the deficit load is imported from the utility or ESS.Sometimes, electricity consumers have surplus power from their usage.In this situation, electricity consumers are able to sell out the surplus electric power to the commercial grid.The proposed optimization model, which is presented in Figure 1, is explained below.

Microgrid
We consider the local microgrid with m renewable energy sources, i.e., photovoltaic cells and wind turbine.The total electricity produced by microgrid in time slot t ∈ T and total generation in a day T is expressed by Equations ( 1) and ( 2), respectively: In Equations ( 1) and ( 2), t and T represent the single time slot and maximum time slots, respectively.One thing that is important to note is that RESs are intermittent in nature [27].A lot of statical models exist to predict the future electricity generation from RESs.We explain the components of microgrids briefly in the next section.

Solar Panel
The proposed energy management scheme tries to maximize user comfort in terms of cost minimization via utilizing electricity in high price hours, which is generated from the microgrid.Solar energy is converted into electricity via photovoltaic cells and converting the direct current (DC) to alternating current (AC) through the converter.Photovoltaic cells performance models are integrated to obtain a maximum power point (MPP) and current-voltage (I-V) curve, which can help to optimize the photovoltaic cells more.Figure 2 depicts the I-V curve, and the performance of photovoltaic cells is calculated by the following relationship: where p is the power generation by solar panel, i L is the light current, i s is the diode saturation current, and series resistance and shunt resistance are represented by R s and R sh , respectively.The ideality factor α = q/n s kT, where k = 1.38 × 10 23 j/K, q = 1.60 × 10 −19 , C is the electronic charge, T = 298 K temperature and n s shows the number of solar cells.In this work, five solar panels are considered for electricity generation, with each being 230 W.

Wind Turbine
The kinetic energy is converted into electric energy via a wind turbine.The electric power that is produced by the wind turbine p t wt in time t is explained by Equation ( 4).This equation calculates the electric energy on the basis of the following parameters: wind turbine blade area, the wind speed and wind turbine efficiency.The wind turbine generates electric energy between cut-in and cut-out wind speeds.The minimum wind speed where the wind turbine generates minimum energy is called cut-in speed and energy generation is 0 when wind speed is less than cut-in speed.The maximum wind speed where wind turbine generates maximum energy is called cut-out speed; it is not risk-free to operate wind turbines when wind speed is more than cut-out speed.Therefore, wind turbine turns to the OFF state due to safety reasons when wind speed is more than cut-out speed and, in this situation, energy generation is p t wt = 0. Usually, the wind speed is high in the daytime and, on the other hand, wind speed is slow at nighttime [28].All constraints of wind turbines are presented in Equations ( 5)-( 7):

ESS
ESS is also installed for storage of electricity and the basic purpose is to exploit the efficiency of the proposed home energy management scheme.ESS stores electricity from the commercial grid when the price is low and also stores from the microgrid in high electricity generation hours.ESS is considered as a shiftable load in this work, and ESS charging and discharging can be scheduled in any time interval in an adaptive way.The capacity of ESS is considered 5 kW in this work and ESS stores a maximum of 90% electricity instead of 100% due to safety reasons.ESS supports the home in the limit of minimum and maximum energy storage levels which are 10% and 90%, respectively.ESS discharges only when the rates of electricity are high or the microgrid is unable to meet electricity demand.When the ESS has maximum storage, the excess electricity sells back to the commercial grid.The stored energy at time slot 't' is expressed in Equation ( 8) [29] with all constraints explained in Labels ( 9)-( 11), the electricity charging/discharging constraints are considered: In Equation (8), SE shows the stored electricity (kWh at time slot 't', η ESS is the ESS efficiency, ES ch is the charging to ESS at time 't' and ES dis shows the discharging electricity from ESS at time interval 't'.

Household Electricity Load
In this work, we consider 24 h for implementation, 1 h for each time slot, expressed as: T = {t 1 , t 2 ......., ........, t 24 }.The total time slots in a day represented by T and t shows the single time slot.Furthermore, the household consists of multiple appliances that are further categorized into three main categories: shiftable appliances (a s ), non-interruptible appliances (a ni ) and base-load appliances (a b ), where a s , a ni and a b ∈ A n (A n is the combination of all appliances).Every appliance is further connected with the internet and capable of communicating with the energy management controller (EMC).EMC is also connected with the internet via WiFi, which shifts the appliances operation according to our fitness function.In our system model, every smart appliance must complete its length of operational time.Figure 3 represents the appliances' execution pattern.Where the α describes the possible earliest starting time for each appliance, β presents the possible least ending time for each appliance and η describes the time interval when an appliance performs its execution.Furthermore, the categorization of home appliances is presented in the next section and the parameters regarding appliances are presented in Table 1.

Categorization of Load
In this section, the categorization of home appliances is uncovered.We have considered a smart home with multiple home appliances in this work [15].Later, the appliances are divided into three main categories/classes named shiftable, non-interruptible and base load appliances.Each category of appliances has different behaviors and constraints that are explained in detail in the next section.

Shiftable Appliances
In this section, shiftable appliances are defined and these types of appliances can be shifted or interrupted in any of the given time period depending upon their necessity.Shiftable appliances class includes the electrical car, vacuum cleaner, laptop, etc.A set of all shiftable appliances are demonstrated by A s and a s ∈ A s demonstrates each appliance in the shiftable category.In Equation (12), the power rating for shiftable smart appliances is shown by λ s .ε s shows the total electricity consumption from the commercial grid or microgrid against shiftable appliances in a day, and is calculated by the equation given below: The per hour electricity cost that is paid to the commercial grid for all shiftable appliances a s can be expressed below: The total electricity cost for one day that is paid to the commercial grid for all shiftable appliances A s is calculated by: Here, α s (t) shows the ON/OFF (i.e., in form of 1 or 0) states of each shiftable appliances.

Non-Interruptible Appliances
In this section, we define the second category of appliances named non-interruptible appliances.This type of appliance may not be interrupted when execution starts but shifted to any time slot before starting their execution.The operation time of non-interruptible appliances cannot be changed.However, this type of appliance may be scheduled between possible earliest starting and possible least ending time.Let a ni ∈ A ni represent each appliance in this category.The λ ni and ε ni express the power rating and electricity consumption of these types of appliances, respectively.The electricity consumption per day against these types of appliances is calculated in Equation ( 16): The hourly and per day total electricity cost can be calculated using Equations ( 17) and ( 18), respectively: Here, α b (t) presents the ON/OFF (i.e., in form of 1 or 0) states of non-interruptible appliances.

Base-Load Appliances
The base-load appliances A b are such types of appliances that cannot be shifted or interrupted while performing their operations.Generally, these appliances considered the main load of any household; these appliances are also called non-shiftable and non-interruptible appliances.We consider interior lighting and refrigerators as base load appliances.Let a b ∈ A b represent a single appliance from the base-load appliances' category.The λ b presents the power rating of each appliance in this category and total consumed electricity ε b in a day is calculated as: The hourly and per day cost against consumed electricity is calculated by Equations ( 21) and ( 22), respectively: In Equation ( 21), the ON/OFF status of base load appliances is presented by α b (t):

Electricity Tariff and Bill Calculation
An Electricity tariff is another dynamic attribute of our proposed system model.The utility company provides different electricity tariffs for consumers' motivation to manage their load requirements.In this work, we consider the RTP signals to calculate the electricity consumption cost.There are two different electricity rates for each time slot (hour); one rate is for electricity purchasing EP pur and the other rate for excess electricity selling EP sell to the commercial grid.However, the electricity selling rate is 90% of the purchasing rate in each hour [30], calculated in Equation (24).The selling and purchasing electricity tariff is presented in Figure 4:  The consumers pay the total costs to utilities against consumed electricity.The electricity cost for a single time interval (hour) without and with microgrid integration is calculated by Equations ( 25) and ( 26), respectively.First, the consumer utilizes electricity from the microgrid in any hour.Then, the remaining electricity demand is purchased from the commercial grid: Similarly, the total cost per day without microgrid and with microgrid is computed by Equations ( 27) and (28), respectively: The decision is taken at the start of each hour against selling, purchasing or storing the electricity.When the electricity rate is cheaper, the smart home tries to purchase electricity for load demand.The generated electricity from microgrids is stored in ESS for future trading.In ON-peak hours, the smart home meets the load from the microgrid or ESS and excess electricity is sold back to the commercial grid calculated in Equation ( 29): where The total amount of exported electricity to the local grid is computed by the following Equation ( 31): The earnings from a commercial grid hourly basis and total for a day is presented in Equations ( 32) and (33), respectively:

Proposed Schemes
A smart meter is installed at every residence (smart home) in the smart grid environment and further EMC is connected with the smart meter.Two-way communication is only possible between electricity consumers and utilities via smart meters.In this work, we investigate the heuristic approaches to solve scheduling and trading problems.CSA and SA are implemented for cost and PAR minimization along with profit maximization.These algorithms make decisions on the basis of electricity generation from the microgrid, price and load in that hour.First, a detailed introduction of SA and CSA is uncovered in this section, and then procedures of SA and CSA in our scheduling and trading problem are explained.

CSA
CSA belongs to a nature-inspired meta-heuristic algorithm family proposed in [31].CSA solves the optimization problems on the basis of the breading behavior of some cuckoo species, features of Lèvy flights of some birds and fruit flies.Some cuckoo species put their eggs in the other birds' nests, which are randomly chosen and these nests are called host nests.The owners of these nests may discover the eggs laid by other cuckoos for breeding.CSA has some rules and finds the best solution via the following rules mentioned below:

•
Every cuckoo lays only one egg in the randomly chosen nest.

•
Only the high-quality nests with the high quality eggs are considered for the next generation.

•
Host nests are fixed and the host birds discover the eggs.
In this work, CSA begins finding the best solution locally from randomly laid eggs (1,0).Each egg laid by cuckoos shows possible solutions and the egg pattern (1,0) shows the ON/OFF status of the appliances, respectively, in each time slot.Every egg (that shows possible solutions) is evaluated in terms of our fitness function: PAR and cost alleviation with maximum earnings.After searching for local solutions (hourly solutions), CSA performs a regeneration step, which is performed on the basis of the best quality of eggs (best local solutions).The discovering probability rate is 0.250 and the parameters of CSA in our work are presented in Table 2.For searching for the best global solution, new solutions X (t+1) are reproduced via Lèvy flights for a cuckoo i [31]: Birds or animals search for their food randomly by nature.The randomization has a significant role in the population based techniques.A Lèvy flight is a random walk in which step lengths are distributed by a high probability distribution.To search for the best global solution as well as generate randomness in the next reproduction, Lèvy flight is performed.

SA
SA is meta-heuristic nature inspired algorithm which is based on the strawberry plant presented in [32].Sometimes SA is also called plant propagation algorithm (PPA).Plants are very intelligent species and plants propagate via runners.Plants manage its survival on the basis of nutrients, light, water and toxic substances.If a plant is in good location/place where it finds enough water, nutrients, etc. then it will never leave this place.In another case, if the plant is in a location, where water, light and nutrients are minimum then it would try to change the location of offspring by sending long runners for finding the optimal location for its survival.The process of sending long runners is called exploration.The plants send few long runners because long runners need maximum sources calculated in Equation ( 35).It is difficult to provide sources to runners especially when the plant is in a not good location with no light and other requirements.Environmental factor decides the location, whether it is good or bad.This underlying propagation strategy is developed for plant survival.Therefore sometimes this is also called PPA which imitates the propagation of plants.A set of some parameters required in SA which are explained in Table 3.The population generation in SA is performed via Equation (36): In our work, SA generates population in the form of 1 and 0 using Equation (36).Each binary number shows a solution for a particular time slot and the binary number represents ON or OFF status of appliances.The SA starts finding the local solution (best locations) via runners on the basis of our defined fitness function, which is cost and PAR reduction with earnings maximization.SA then tries to search for global solutions by performing reproduction steps on the basis of local solutions (best locations).

Case Studies
In this work, three case studies are presented to demonstrate the performance of our proposed scheme from both the perspectives of the smart home/consumer and the electric grid.In the first case study, the home has no intelligence capabilities; put simply, we consider a conventional home and the electric grid.The home purchases and utilizes the electricity conventionally without knowing the electricity tariff.In the other two cases, households with different properties are considered (i.e., integration of wind turbine, solar panel and ESS) and compared with each other from both customer and electric grid perspectives.Each case study has a transient phase in which every smart home makes autonomous decisions in interaction with the electric grid; the smart home can purchase, sell, store the electricity or shift the load.Eventually, the overall performance of the proposed system will reach equilibrium.Multiple parameters defined for our case studies are shown in Table 4, where wind cap h , solar cap h and ESS cap are average hourly electricity generation from a wind turbine, solar panel and average storage capacity of ESS, respectively.V cut−in and V cut−out show the cut-in and cut-out speed of wind where the wind turbine generates minimum and maximum electricity, respectively.Furthermore, we also consider assumptions for the operation of ESS.The minimum remaining storage, maximum charging level and rate of charging/discharging are the constraints that are considered in this work.

Simulation Results
In this section, to evaluate and demonstrate the versatility of our proposed scheme, simulations are carried out.Then, simulation results are shown to uncover an optimal scheduling and power trading for the household.We perform simulations multiple times and then we present the results' average of 20 runs.Two algorithms (CSA and SA) are implemented to critically analyze and validate our proposed scheme.We consider a smart home consisting of 12 different smart appliances and each have different living habits (i.e., power rating and LOT) explained in Table 1.
Furthermore, these appliances are categorized into three different categories (see Section 3.4).All of the appliances' parameters that are used in our simulations are presented in Table 1.Base-load appliances may not contribute to minimizing electricity costs or PAR because these appliances cannot be shifted and must be ON according to user preferences.In our simulation setting, the operation time is considered 24 slots, 1-h each, beginning from 8 a.m. to 8 a.m. on the next day.We consider RTP signals for electricity cost calculation and RTP signals are presented in Figure 4. Experiments/simulations of our proposed model were executed on a computer system with an Intel Core i7 CPU 2.8 GHz processor, 8 GB RAM, and Windows 10 Operating system.Furthermore, MATLAB is used as a simulator in this work.

Case 1: Home without Energy Management and Microgrid
In this case, we have studied the operation of a conventional home without a microgrid and ESS integration.This conventional home is not able to manage its electricity consumption and does not have any excess electricity to sell back to the electric grid.In addition, the home cannot make any decisions about electricity usage.It blindly purchases and utilizes electricity while ignoring the electricity tariff or any other parameters.
Figure 5 depicts the electricity bought by conventional homes from electric grid and pricing signals.The results clearly demonstrate that the conventional home ignores the pricing signals and blindly utilizes the electricity.The conventional home purchases electricity in time slots 9 and 10 when the price is at a maximum and also creates peaks due to maximum electricity consumption.Therefore, the conventional home would pay maximum electricity costs against blind utilization of electricity.The hourly and total electricity cost against unscheduled consumption are presented in Figures 6  and 7, respectively.However, the results presented in this section consider a baseline for our later comparisons.

Case 2: Home with Energy Management but without Microgrid
Energy management of a home is considered in this case and the smart home is able to manage its electricity consumption.The shiftable appliances may have shifted from ON-peak to OFF-peak hours.EMC is installed in this case and EMC shifts the load according to price and load information.Figure 8 represents the hourly electricity consumption without energy management and with energy management using SA and CSA.The result demonstrates that electricity consumption is high without energy management in ON-peak hours; however, electricity consumption is low in ON-peak hours using SA and CSA.Our proposed algorithms efficiently shift the load while minimizing the PAR, which is presented in Figure 9. CSA shows high performance for PAR reduction as compared to SA and an unscheduled case.The PAR reduction is 15% and 45% using SA and CSA, respectively.We minimize the hourly electricity cost by energy management, and, eventually, per day total electricity cost is minimized.Figure 6 depicts the hourly electricity cost, which clearly shows that electricity cost is at a minimum in ON-peak hours using our proposed scheme, as compared to unscheduled energy consumption patterns.The total electricity consumption cost against one day is presented in Figure 7.It may be observed from the results that the electricity cost is at a minimum using CSA when we compare with SA and unscheduled consumption of electricity.However, the electricity cost paid using SA is lower than the unscheduled electricity consumption.In case 2, the total electricity cost reduction is 26% and 36% using SA and CSA, respectively.

Case 3: Home with Energy Management and Microgrid
In this case, the smart home is similar to case 2; however, a microgrid with ESS is considered here.The smart home is able to make decisions at every hour to shift the load, purchase, sell or store electricity.In this case, a smart home imports electricity when rates are low and in ON-peak hours the load requirement is met by the microgrid, and the excess electricity is sold back to the commercial grid against high prices.The smart home earns maximum profit with this activity.Figure 10 shows the electricity generation from a wind turbine and solar panel.The electricity generation from the microgrid is at a maximum in ON-peak hours because, in the daytime, the wind speed and solar irradiation are at a maximum.However, the electricity generation is low at nighttime or in the morning when solar irradiation and wind speed are minimum or 0. Figures 11 and 12 represent the relationship of electricity generation from a wind turbine and wind speed, and electricity generation from solar panels and temperature, respectively.When wind speed is at a maximum, electricity generation is at a maximum and vice versa.The total imported and sold electricity by both algorithms SA and CSA are presented in Figure 13.The results represent both algorithms showing high performance.Firstly, load is shifted in OFF-peak hours and then the generated and stored electricity in ON-peak hours is sold.If a home performs this act efficiently, it earns a maximum profit through electricity trading.Furthermore, our proposed CSA shows high performance as compared to SA in terms of load shifting and power selling in high price hours.Figure 14 depicts the total electricity cost against imported electricity and total earnings against sold electricity.Our proposed algorithm CSA shows supremacy in terms of electricity cost reduction and earnings maximization as compared to SA.The basic reason behind efficacy of CSA is that CSA has lesser parameters to be fine-tuned.

Performance Comparison
In this section, we provide the comparison of the three case studies previously presented and our proposed scheme using SA with CSA.According to Figure 7, the proposed scheme using SA and CSA minimized the total electricity cost as compared to case 1.Furthermore, when we compare case 2 with case 3, the electricity cost is reduced more in case 3 and presented in Figure 14.The total imported electricity from the external grid is also minimized in case 3 when we compare with case 1 and case 2, which is shown in Figure 13. Figure 9 shows the PAR against case 1 and case 2, and results clearly demonstrate that case 2 has minimum PAR as compared to case 1.In case 3, ESS is also taken into account for reliable and stable grid operation.power trading is only possible in case 3 and the total revenue generated from power trading is depicted in Figure 14.The overall comparison is presented in Table 5.It is clearly seen from Table 5 that our proposed scheme using CSA outperforms as compared to SA in all case studies.

Conclusions
In this paper, an electricity load management scheme is developed using SA and CSA along with an RTP scheme for DSM.We considered the load scheduling and power trading problem simultaneously in a smart home that has a grid-connected microgrid.An ESS is also installed to enhance the microgrid performance and reliable operation.The smart home makes autonomous decisions against selling, purchasing or storing electricity according to electricity generation and pricing signals.Furthermore, a comparison of different case studies has been provided to investigate the effectiveness of our proposed scheme.Simulation results demonstrate that our proposed scheme outperforms in terms of electricity cost and PAR reduction with maximizing the earnings.It has been observed from simulation results that the proposed scheme using SA and CSA minimized the electricity cost by 26.63% and 36.42%,respectively, in case 2, and by 56.26% and 62.83%, respectively, in case 3.In addition, our proposed scheme using SA and CSA earns 173.39 and 249.39 (cents), respectively.
The overall performance of CSA is superior to SA because the CSA spends a maximum amount of time on global search instead of local search.
In the future, we will focus our research on implementing the mathematical techniques for cost and PAR alleviation in addition to electrical vehicle integration as mobile storage.We will also implement this model in different electricity consuming sectors i.e., industrial and commercial.
Acknowledgments: This project was full financially supported by the King Saud University, through the Vice Deanship of Research Chairs.
Author Contributions: All authors have equal contribution.

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

Figure 4 .
Figure 4. Hourly electricity purchasing and selling rates.

Figure 10 .
Figure 10.Electricity generation from wind turbines and solar panels.

Figure 11 .
Figure 11.Relationship between electricity generation from wind turbines and wind speed.

Figure 12 .
Figure 12.Relationship between electricity generation from solar panels and temperature.

Table 1 .
Parameters of home appliances.

Table 2 .
Parameters of CSA.

Table 3 .
Parameters of SA.

Table 4 .
Input parameters for case studies.
Shows electricity demand of shiftable appliances in a home ε ni Shows electricity demand of non-interruptible appliances in a home ε b Shows electricity demand of base-load appliances in a home α s Show ON/OFF state of shiftable appliances category earn Hourly earnings T Total per day earnings