A Shrinking Horizon Model Predictive Controller for Daily Scheduling of Home Energy Management Systems

In this paper, the model predictive control (MPC) strategy is utilized in smart homes to handle the optimal operation of controllable electrical loads of residential end-users. In the proposed model, active consumers reduce their daily electricity bills by installing photovoltaic (PV) panels and battery electrical energy storage (BEES) units. The optimal control strategy will be determined by the home energy management system (HEMS), benefiting from the meteorological and electricity market data stream during the operation horizon. In this case, the optimal scheduling of home appliances is managed using the shrinking horizon MPC (SH-MPC) and the main objective is to minimize the electricity cost. To this end, the HEMS is augmented by the SH-MPC, while maintaining the desired operation time slots of controllable loads for each day. The HEMS is cast as a standard mixed-integer linear programming (MILP) model that is incorporated into the SH-MPC framework. The functionality of the proposed method is investigated under different scenarios applied to a benchmark system while both time-of-use (TOU) and real-time pricing (RTP) mechanisms have been adopted in this study. The problem is solved using six case studies. In this regard, the impact of the TOU tariff was assessed in Scenarios 1–3 while Scenarios 4–6 evaluate the problem with the RTP mechanism. By adopting the TOU tariff and without any load shifting program, the cost is <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>1.2274 while by using the load shifting program without the PV and BEES system, the cost would reduce to <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>0.8709. Furthermore, by using the SH-MPC model, PV system and the BEES system, the cost would reduce to <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>-0.282713 with the TOU tariff. This issue shows that the prosumer would be able to make a profit. By adopting the RTP tariff and without any load shifting program, the cost would be <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>1.22093 without any PV and BEES systems. By using the SH-MPC model, the cost would reduce to <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>1.08383. Besides, by adopting the SH-MPC, and the PV and BEES systems, the cost would reduce to <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>0.05251 with the RTP tariff, showing the significant role of load shifting programs, local power generation, and storage systems.

Parameters: The lower bound of the appliance i for the baseline operation.
The upper bound of the appliance i for the baseline operation. C ON i Turn-on cost of the controllable appliance i ($). C OFF i Turn-off cost of the controllable appliance i ($).

E ES
Minimum stored energy in the BESS (kWh).

E ES
Maximum stored energy in the BESS (kWh). P N Maximum power that can be transacted between home and grid (kW). P PV Maximum power that can be generated by the photovoltaic panel (kW). P ES,Ch. Maximum charging power of the BESS (kW). P ES,Dis. Maximum discharging power of the BESS (kW).
The lower bound of allowable utilization of controllable appliance i.
The upper bound of allowable utilization of controllable appliance i. The hourly price of energy sold to the grid by home at time interval t ($/kWh). λ G→H t The hourly price of energy sold to home by the grid at time interval t ($/kWh).

I. INTRODUCTION A. MOTIVATION
The increasing rate of renewable power generation at lowvoltage levels has increased the flexibility of end-users to actively participate in maintaining some share of their demand in a green way and meanwhile with reduced costs. In this way, rooftop photovoltaic (PV) panels are popular resources that have been installed by prosumers at lowvoltage levels. However, such resources are only able to produce energy during daylight hours while a considerable share of energy consumption of residential consumers is during nighttime. To reduce the impacts of uncertain power generation and in relation with the consumption pattern, the installation of battery electrical energy storage (BEES) units has been recommended. In this regard, the optimal combination of BEES devices and PV panels considering the techno-economic aspects can improve the functionality of local energy systems for the active prosumers [1]. This paper proposes an integrated model for smart homes augmented by a home energy management system (HEMS) to reduce electricity costs based on user demand, while optimally scheduling controllable electrical loads and operation of the BEES unit. As residential consumers are categorized as price-taker participants, their consumption patterns can be effectively changed by price signals and other incentives extensively introduced in demand response programs [2]. Recent advances in communication systems and internetof-things (IoT) have provided the required infrastructure to implement smart homes being capable of self-scheduling home appliances. This feature is available through a controller that is optimally programmed, which enables the consumer to change their role in the electric power system. In this respect, the consumers can effectively control their energy consumption and the corresponding costs by utilizing smart controllers and meters. Furthermore, by purchasing an BEES system with joint operation with other smart devices, along with the optimal self-scheduling of assets, the consumer could benefit from various demand response programs offered by the utility. Smart homes are typically equipped with considerably high-consumption assets such as spin dryers, electric vehicles (e.g., charging stations), and washing machines. Optimal scheduling the operation times of such devices would result in significant decline in the energy costs of the consumer. It should be noted that the BEES system operation is associated with intertemporal constraints. Furthermore, end-users have their daily patterns of electricity VOLUME 10, 2022 consumption that may vary from day to day. This introduces the need for a shrinking horizon model for the self-scheduling of home appliances in a specific day, considering the expected PV power generation and other activities related to meteorological data. This paper addresses the mentioned issues and proposes an integrated SH-MPC for HEMS application in the presence of PV and BEES units to minimize daily electricity costs. Accordingly, a mixed-integer linear programming (MILP) model is developed for the HEMS application while the objective is to minimize the electricity bill of the consumer on the given day. In this regard, the consumer is equipped with local power generation through the solar PV systems operated jointly with the BEES system, while the impacts of the real-time pricing (RTP) mechanism and timeof-use (TOU) tariff have been investigated in relation to the aforementioned optimization problem.

B. LITERATURE REVIEW
There are some initiatives and incentives to promote renewable and clean energy harvestings introduced in the research projects in the world to increase the penetration rates of renewable energy sources. In between, residential end-users can also benefit from a fully automated energy system installed and equipped with PV panels and BEES units at their local sites. The main task of the HEMS is defined as enhancing the consumption of homes that needs some particular equipment. For example, the residential assets are required to have interaction through specific communication links to enable control and monitoring. Furthermore, the house is supposed to have bidirectional communication with the utility grid to receive the signals of demand response programs. Some data processing tools are also required in this framework. The HEMS would provide the consumer with operation patterns with respect to the energy consumption data of the home, the target of the scheduling, the preferences of the consumer, and also the energy price. It is noteworthy that cyber security issues should also be addressed in such systems [3], [4]. HEMSs have been discussed throughout the literature. Ref. [5] presented an MILP model for the optimal scheduling of home appliances, taking into consideration electric vehicles (EVs) and static BEES systems. In this respect, a holistic model has been developed addressing the operational preferences of homeowners. Accordingly, the lowest electricity bill and the highest possible comfort level would be ensured by using the mentioned framework. A dynamic stochastic optimization model has been developed in Ref. [6] to address the energy management problem of a smart home that is equipped with a plug-in EV (PEV). The presented framework can minimize the ratepayer cost while meeting the operational requirements of the home and the PEV. Ref. [7] presented a three-level energy management system for a smart home with solar power generation through a rooftop PV panel. In the first level, solar power generation is forecasted. In the second level, the day-ahead scheduling problem is solved for minimizing the operating cost of the home; and in the third stage, the operation of the home assets would be corrected by applying an MPC-based operational decision. A deep reinforcement learning framework has been proposed in [8] for the HEMS operation with both thermal model and input parameters' uncertainties. This framework would overcome the difficulties with the necessity of knowing the uncertain parameters and the precise model for the thermal system. Besides, the application of artificial intelligence to the HEMS scheduling problem has been studied in [9]. An energy management system has been proposed in [10] for a smart home equipped with a PEV, solar PV panel, and BEES while employing demand response programs. The objective function of the problem is to minimize the cost while investigating the performance of various demand response programs. An end-user comfortoriented smart HEMS has been designed in [11] for the sake of minimizing the daily electricity bill of the end-user while taking into account local renewable power generation. The optimal operation of the heating, ventilation, and air conditioning (HVAC) system in the HEMS has been addressed in [12], [13] while using the TOU tariff and addressing the user's discomfort index. The operational orders of home appliances within the HEMS scheduling problem have been investigated in [14] by using the value of loss of load of each device. A bidding strategy model was suggested in [15] providing the end-user with an efficient tool to decide on the optimal operation of home appliances, local storage, and generation assets while transacting power with the utility grid. A MILP framework was developed in [16] to investigate the end-user comfort-oriented HEMS scheduling problem with different demand response programs. Moreover, the self-scheduling problem of HEMS taking into consideration the end-user comfort and operational preferences while addressing price-based demand response programs has been studied in [17]. A controller has been designed in [18] for the HEMS to minimize the amount of the daily electricity bill of a residential end-user with various load types by using dynamic price signals. A HEMS has been designed in [19] for the day-ahead scheduling of home appliances and a PEV within a predictive stochastic optimization framework. The internet of things and big data methods have been deployed in [20] for the scheduling of home appliances each equipped with a data acquisition module. A comparative study has been carried out in [21] to address the stochastic models used for the HEMS scheduling problem in the presence of solar PV systems, PEVs, home appliances, and heat pumps. Ref. [22] has developed a decentralized dayahead scheduling framework for interconnected HEMSs so as to minimize the daily energy costs of end-users. In this respect, the energy sharing among HEMSs has been studied while dynamic pricing has been deployed. The Q-learning and fuzzy reasoning has been utilized in [23] as a modelfree approach to solve the HEMS scheduling problem in the presence of solar PV panel and BEES system. The real-time operation of a HEMS has been investigated in [24] by using an IoT-based self-learning model. The alternating direction method of multipliers (ADMM) as a distributed optimization technique was employed in [25] for the coordinated operation of interconnected neighborhood HEMSs, aiming at minimizing the daily electricity bill of end-users. A straightforwardstructure HEMS was designed in [26] with the capability to implement demand response programs. The impacts of HEMS on the electrical energy consumption and also the consumption pattern of the end-user have been studied in [27]. A tri-level optimization model has been developed in [28] for the coordinated operation of a HEMS and the Volt/VAR optimization in low-voltage and medium-voltage distribution systems, respectively. Ref. [29] studied the resilience of a HEMS equipped with a BEES system facing extreme weather conditions. A four-stage HEMS operation framework has been designed in [30] in the presence of solar power generation and BEES system. A stochastic mixedinteger non-linear programming model has been introduced in [31] for the day-ahead scheduling of a HEMS in the presence of BEES and solar PV systems and electric water heaters. As mentioned previously, the HEMS scheduling problem is associated with parameter uncertainty. In this respect, more precise modeling of the impact of uncertainties would be achieved provided that the correlation between the uncertain parameters is considered as in [32] using the Copula. A smart HEMS was proposed in [33], addressing the impacts of different scenarios of power costs on the daily electricity bill of the consumer. Furthermore, the particle swarm optimization (PSO) algorithm and the binary PSO (BPSO) have been introduced in [34] for the multiobjective day-ahead scheduling of a renewable energy-based grid-supported smart home to simultaneously optimize the daily energy cost of the consumer and the peak-to-average ratio as well. An efficient energy management system has been proposed in [35] for interconnected microgrids with smart homes by using a multi-objective optimization model. Ref. [36] addressed the HEMS problem within a network of microgrids and Ref. [37] presented an energy management system based on a MILP model for microgrids. A triobjective optimization framework has been presented in [38] to simultaneously optimize the energy cost, peak-to-average, and the residential users' comfort, where the home was equipped with a BEES and renewable power generation and automated demand response programs' impacts have been investigated. Also, A bi-objective MILP model has been presented in [39] for the optimal day-ahead HEMS scheduling.
• Accordingly, the research gaps to cover are as follows: • Assessing that how optimal scheduling varies with respect to the variations of PV power generation during the day.
• The need for developing a shrinking-horizon model predictive control model to meet the total energy demand by the end of the scheduling period and initialize conditions for the next day.
• The need to enhance flexibility as one of the services by dedicated prosumers in demand response programs.
• Application of the battery in the uninterrupted operation of assets when necessary.
• Developing a fast and efficient mixed-integer linear programming addressing the prosumer's comfort.

C. CONTRIBUTIONS
The main contributions of this paper are as follows: • Providing the optimal scheduling of PV and BEES in HEMS using an efficient MILP model.
• Investigating demand response programs for smart homes with controllable loads.
• Presenting a user's comfort-oriented self-scheduling model.
• Developing SH-MPC for the HEMS application utilizing meteorological data.

D. PAPER ORGANIZATION
The organization of the paper is as follows. Section II provides the key concepts of the HEMS, while the self-scheduling model of the HEMS with local power generation in the house is presented in Section III. The mathematical formulation of the proposed model is presented in Section IV. Section V proposes the simulation results. Finally, relevant conclusions and future recommendations for research are summarized in Section VI.

II. HOME ENERGY MANAGEMENT SYSTEM
This section provides the main principles of the HEMS. Different home appliances can be effectively controlled and scheduled by end-users or even by an automated energy management system. The performance of the energy management system would increasingly improve by an adaptive strategy, whose implementation is the main target of this paper. In the automated energy management system, home appliances can be controlled in an effective way to fulfill the end-user's preferences while impressively reducing the electricity bills. In the HEMSs, there are some controllable loads as well as other fixed and interruptible ones. However, the main focus of the current study is on shifting the controllable loads, which are the most dominant part of the end-users' demand that can be changed or shifted to minimize the electricity bill. Figure 1 illustrates the main concept of the HEMS and controllable loads in a typical smart home. In this paper, the optimal control strategy for the least-cost self-scheduling of controllable home appliances is proposed. It should be noted that both local PV generation capability and energy storage possibility have been studied in this framework.
The 'plugging time' for each application and device varies depending on the user and their lifestyle preferences. In this case, the base time and possible time interval for each asset should be determined before the self-scheduling is organized by HEMS. Moreover, the plugging-in sequence of some appliances should be properly met. For example, the spin dryer should be operated after accomplishing the washing machine task. In this structure, the end-user has the option of charging and discharging the BEES according to different electrical energy tariffs. In addition, the consumer benefits from the installed PV panel to minimize the electricity bill. It should be noted that some expenses for installing such assets as well as their corresponding maintenance and operation costs are imposed on active consumers. Therefore, the consumer should assess the total saving of the electricity bill incorporating the costs of HEMS, PV, and BEES to determine the optimal configuration of the energy storage and PV panel size, which is beyond the scope of the current study. One of the permissible goals of introducing HEMS is to provide an efficient energy management system at the low-voltage level for residential loads. A sustainable energy system including PV and BEES can increase the flexibility of the distribution networks by load factor enhancement and active power injections at the consumption nodes of the grid. Furthermore, increasing the penetration rate of electric vehicles introduces new challenges to both end-users and distribution grid operators to fulfill the technical constraints, and power and energy needs of such new electrical loads (and also suppliers in the vehicle to grid technology). However, the HEMS can provide a flexible and controllable strategy for charging at home. All in all, the HEMS can provide the following benefits for end-users: • Efficient and reliable energy management system for the end-users.
• Energy consumption monitoring to improve the load factor.
• Effectively activating demand response programs and energy consumption enhancement.
• Introducing some flexibility to the distribution network operator and active participation in local energy communities. In the case of installing PV panels and BEES devices, the flexibility provided by the active end-users will effectively increase and the prosumer can benefit from energy and flexibility provided in the market through consumption profile modifications. This, in turn, can introduce more flexibility to the grid during peak hours as well as contingent events in which the network operator needs fast resources to serve the critical loads.
The concept of smart homes usually requires some infrastructure such as sensors and actuators to control electrical and mechanical assets. Modern home appliances are equipped with smart controllers coordinated with the central control system of the HEMS to perform different tasks. This paper considers that the home owner is able to run the self-scheduling of the home appliances with respect to their operational preferences. Accordingly, a developed framework would be used by a central agent through IoT platform to facilitate the communication between the home appliances and the central coordinator.

III. SH-MPC AND HEMS INTEFACE
This section provides the conceptual model of the problem studied in this paper. The model includes two main parts. In the first part, the SH-MPC model is established while in the second part, the self-scheduling problem of HEMS is developed. In SH-MPC, the meteorological data and other input data are fed as well as the main observed decision variables of the inner loop, i.e., HEMS. For the next predictions, HEMS needs the ongoing tasks to be continued as well as access to the updated meteorological data. It should also be noted that for each controllable asset, it is necessary to accomplish the task and no interruption is allowed for the running assets if they have already started their task (until the accomplishment of their task). In such case, the shrinking horizon can provide a new operating horizon for each asset that is operating. It means that for the running appliances, the associated binary decision variables representing the operation of the asset are considered fixed parameters for the subsequent time intervals and the HEMS should respect the required operation time to be maintained. The main output results which will be used in the SH-MPC are the state of charge (SoC) of the BEES and the status of the running assets, including the start time and the remaining time slots for the next predictions. As Fig. 2 illustrates, in the SH-MPC and HEMS model, the daily operation strategy will be determined. Therefore, the shrinking horizon strategy is developed for this specific problem.
As can be observed in Fig. 2, the self-scheduling problem is solved for each prediction time slot continuously and the solving time would reduce in proportion with each observation slot being realized. This means that the self-scheduling problem is solved for 24 hours at the beginning of the day and after passing each time slot, the problem would be solved only for the subsequent time slots. As a result, the number of decision variables and also their variation ranges would follow a descending trend by passing time. It is worth noting that this is due to the shrinking horizon enabling the consumer to cover all scheduled activities during the day. As can be observed in Fig. 2, the self-scheduling problem is solved for each prediction time slot continuously and the solving time would reduce in proportion with each observation slot being realized. This means that the self-scheduling problem is solved for 24 hours at the beginning of the day and after passing each time slot, the problem would be solved only for the subsequent time slots. As a result, the number of decision variables and also their variation ranges would follow a descending trend by passing time. It is worth noting that this is due to the shrinking horizon enabling the consumer to cover all scheduled activities during the day.

IV. PROBLEM FORMULATION
This section presents the self-scheduling problem of the HEMS for electrical energy management in the presence of local generation and storage assets. The problem mainly aims at minimizing the electricity bill of the customer. Thus, the cost caused by transacting energy with the grid should be included in the objective function. As a result, the objective function of the self-scheduling problem would be defined as minimizing the following function: The objective function comprises three parts. The first term relates to the energy transaction cost including the cost due to purchasing energy from the grid and selling the surplus energy to the grid. The purchase price can be defined through TOU tariff and RTP mechanism while the selling price would be in accordance with the tariff determined by the distribution company (1), as shown at the bottom of the page.
Note that in the transaction cost term, the operation time of assets has been multiplied to the whole term to calculate the energy and energy cost. The second term in (1) corresponds to the discomfort cost caused by the customer's discomfort due to shifting controllable loads. As seen, the discomfort cost is formulated through a linear coefficient of the shifting time. In fact, this cost is inserted into the objective function as a penalty that relates to using appliances before or after the desired time intervals of the consumer and it is considered as a fixed penalty for each asset and time slot. As a result, the further the shifting time, the higher the penalty applied to the objective function. Lastly, the third term represents the cost due to interrupting controllable loads. It is obvious that assets' turning on/off is permitted only once and any further on/off would impose a significant penalty applied to the objective function. This paper takes into account a substantial penalty factor (last term of the objective function with negative sign) to avoid undesired on/off of assets. Furthermore, the constraints of the self-scheduling problem are as follows: (2) shows the power balance constraint for each time interval of the self-scheduling model. The left-hand side of this equation includes the power purchased from the grid, the PV power generation, and also the discharging power of the battery. The right-hand side of the equation comprises the power sold to the grid, the charging power of the battery, and also the load including fixed and shiftable loads.

B. POWER TRANSACTION CONSTRAINT
Generally, any consumer connected to the grid is under a contract with the distribution network in terms of the power or ampere, mainly impacting the coincidence factor of consumers at each time slot. Indeed, the more the load demand, the higher fixed cost the consumer is supposed to pay to the distribution company. Besides, the consumer would not be (1) VOLUME 10, 2022 able to shift the entire load demand to off-peak time slots.
In case the consumer faces any surplus power generation, it would affect the selling power to the grid. It should also be noted that the consumer cannot buy and sell power from/to the grid at a specific time slot. Hence, the power transaction constraints with the grid would be stated as per (3)- (5): The BEES system is usually operated jointly with the solar PV system to store the surplus solar power generation when there is no demand. This storage system would help stabilize the solar power generation during the hours with zero/negligible generation and also during peak-load hours with a shortage in power generation. The BEES system is imposing different constraints on the problem associated with the charging and discharging modes as well as the amount of energy stored in the system. Constraints (6) and (7) show the charging and discharging limitations in each time slot. It is noteworthy that the corresponding variables have been assigned to the model as positive variables. In order to eliminate the conflicting states in the BEES operation, two binary variables have been considered in the model ensuring that the BEES operates in either charging/discharging/idle mode as depicted in (8). Equation (9) represents the hourly energy status of the storage system taking into account charging and discharging efficiencies. Constraint (10) states that the amount of energy stored in the storage system at the beginning and the end of the self-scheduling period should be identical. The limitation on the amount of energy available in the storage system is presented in (11). The lower and upper bounds on the amount of energy stored in the system are usually determined by the manufacture to guarantee the battery health throughout the lifetime.

C. PV POWER GENERATION CONSTRAINT
The amount of solar power generation directly depends upon the capacity of the solar system, the amount of solar irradiance, and also ambient parameters. However, the net solar power generation is assumed to be independent of the number of cells, the configuration, and also the efficiency. In this regard, a parameter is estimated and delivered to the consumer. The amount of solar power generation would be available by using the defined API. Accordingly, solar power generation would be assigned to the model as a parameter:

D. FIXED AND CONTROLLABLE LOADS CONSTRAINTS
Demands of the customers are divided into fixed and controllable loads. It is not possible to change or shift the fixed loads like the refrigerator, freezer, and lighting system. The corresponding costs would constantly appear in the electricity bill. As a result, fixed loads would not impact the objective function of the self-scheduling problem in the absence of local power generation and ESSs. It is noteworthy that local power generation and storage systems increase the prosumers' flexibility to supply these loads such thatno energy purchase from the grid is required during some hours. Thus, fixed loads have been assigned to the model as an input parameter. On the contrary, the controllable loads of the customer can be shifted to other time slots before and after the base load time intervals. It should be noted that shifting the load demand causes customer discomfort which has been already taken into account in the objective function.
In fact, the customer would tend to shift the load demand in case the benefit obtained by cost reduction is more than the amount of discomfort cost. Controllable and fixed loads can be modeled as a string of binary variables and parameters such that the value of the binary variable/parameter would be ''1'' provided that the asset is running. Fixed loads have been characterized by utilizing equations (13) through (15). The binary variable corresponds to the operation of fixed loads which would be equal to ''1'' for the permitted operation interval; otherwise, it would be ''0''. Note that fixed loads have been assigned to the model as a variablewhose value would be exactly equal to the fixed parameter of the permitted operation interval. The permitted operation interval of the i-th fixed load is defined by Ti.
t∈T c Likewise, controllable loads can be modeled by using the above-mentioned strategy while the binary variable would select the best slot of the operation interval. Note that the permitted operation interval of controllable assets is greater than the desired operation interval and the consumer must necessarily decide on the interval T i out of the operation interval of the asset. Relationships (16)- (18) are used to model the controllable loads.
29722 VOLUME 10, 2022 t∈T c S i,t = T i ∀i ∈ N c (17) i∈N c S i,t P c i = P C t ∀t ∈ T c (18) As mentioned before, controllable loads must be operated for a given interval in a continuous way. No interruption is allowed during their operation; otherwise, it leads to degradation or even severe damages to the load. Thus, shut-down and start-up costs have been considered in the objective function to avoid any interruption in their operation. It should be noted that only and only one startup and shutdown is allowed for each asset as assigned to the objective function,meaning that any further startups and shutdowns would result in increasing the costs. Since the corresponding operational variables are binary, any change in the status from ''0'' to ''1'' shows startup, and any change from ''1'' to ''0'' indicates the shutdown. For the refrigerator and freezer as fixed loads, no startup/shutdown is permitted over the self-scheduling period.
It is worth noting that the startup and shutdown constraint within the operation interval is only intended for controllable loads as the operation time of fixed loads is specified within the permitted operation interval,which is not needed to to be mathematicallly modeled.

E. LOAD SHIFTING
A linear penalty factor has been used in this paper to characterize the discomfort index. The cumulative rolling mapping method has been utilized to determine the shifted intervals. Thus, equations (20) and (21)are used to calculate the discomfort index as a result of changing the operation slots to the time intervals other than the baseline slots. In this respect, and denote positive variables as depicted in (22) and (23), respectively. Hence, for any state that the right-hand sides of inequalities (20) and (21) become negative, any contradictory state between the two variables would be omitted.

V. SIMULATION RESULTS
The developed self-scheduling model for the HEMS has been simulated and evaluated for a smart home consisting of a set of home appliances with fixed and controllable load demands, besides a PEV. The load data as well as baseline and permitted operation intervals for each appliance are from a benchmark. The problem is investigated for both TOU and RTP tariffs through several scenarios (see Table 1). The data of the BEES system, the solar PV panel, and its net power generation are given in Table 2. Furthermore, it is assumed that the electrical energy storage system starts the scheduling period with the SOC=50% and it is supposed to end the scheduling period with the same amount of energy. Also, the operating cost of the battery is assumed negligible and excluded from the model. Fig. 3 depicts the day-ahead solar power generation with 30-min intervals along with the online prediction for the ahead intervals up to the end of the day. It is noted that since there are 96 more figures and it is not possible to add them in the figure, only real and forecasted ones have been provided with triangle and square marks and the others are marked with circle marks. Moreover, the exact amount of solar power generation at each time slot and the predicted solar PV generation at the beginning of the day have been illustrated. It is noted that the values are reported in p.u. and the installed capacity of the solar panel is 5 kW. It is assumed that the energy purchase price and selling price are identical justifying the performance of the BEES system in modifying the load profile of the system even without any demand response programs and charge received from the solar PV panel. Moreover, the penalty for shifting the prosumer's load demand has been neglected to achieve the best result in reducing the electricity bill of the consumer through shifting the load demand. Table 3 shows the hourly TOU tariff and RTP mechanism.
As mentioned before, prosumers have both fixed and controllable loads whose effects are studied in this paper. Tables 4 and 5 represent the data of the consumption time and power of each fixed and controllable load. Note that the consumption power of the fixed loads varies over the scheduling period and accordingly, the 24-hour load pattern has been used. Besides, the superscript '' * '' refers to the optimal start and end time of using the assets. This issue for fixed loads has been addressed by defining the permitted operation  status. In other words, fixed loads have been modeled as parameters. The duration of one time slot is considered to be 30 minutes in this paper. It should be noted that different capacity and time slots are assigned to the lighting system model according to the prosumer's priorities and by taking into consideration the conditions before and after the sunrise and sunset, respectively.
A. SELF-SCHEDULING BASED ON TOU Scenarios 1-3 relate to studying the problem by using the TOU tariff. Hence, the electricity price would be pre-given to the customer which is based on the time tariffs. As a result, the end-user would be able to appropriately manage the energy consumption with respect to the tariffs. In this section, three scenarios are studied. In the first scenario, the TOU tariff is only considered and the customer would be a user. In the second scenario, the SH-MPC model is used together with the TOU mechanism. From the optimization and MPC point of view, scenarios 1 and 2 should result in the same solution in the absence of the BEES system and PV power generation that add flexibility and uncertainty to the system, respectively. The MPC would be able to optimally   determine the operating point of the system for the ahead time intervals based on the uncertainties. As a result, if the variation ranges are specified in the HEMS self-scheduling problem, the results of scenarios 1 and 2 would be identical in terms of the operating cost. It is worth mentioning that there are multiple optima with identical values of the cost for the HEMS self-scheduling problem while the schedules may be different. The performance of the SH-MPC has been studied in scenario 3. To this end, the solar PV power generation, which is updated every 30 minutes for the subsequent time slots, has been used. Furthermore, the amount of energy stored in the BEES system would be determined with respect to the optimal selling/purchasing strategy to/from the grid and also, the optimal storage strategy. It is noted that the amount of energy available in the battery should meet 50% of the capacity of the storage system at the end of the scheduling period. For the running appliances, they should operate until the end of the time required for accomplishing their operation; otherwise, a penalty is applied to the cost due to the startup/shutdown costs. The simulation results of each scenario have been discussed in the following: This scenario studies the self-scheduling problem of the HEMS with fixed and controllable loads. For the case with the TOU tariff, the electrical energy cost for the studied day without any load shifting is $1.2874 while the contributions of fixed and controllable loads are $0.2484 and $1.039, respectively. The total energy consumption of the consumer is 39.01 kWh while the contributions of the fixed and controllable loads are 9.96 kWh and 29.05 kWh, respectively. It is noteworthy that the BEES system and solar power generation have been neglected in this scenario and accordingly, the entire load demand of the consumer must be supplied by the utility grid. In this case, the electricity bill of the consumer reduces to $0.8709 while the PEV has the largest share in the cost reduction by $0.1925 with the demand-side management program. It should be also noted that shifting the load demand of some appliances like the spin dryer, cooker hob, cooker oven, and microwave oven would not affect the electricity bill of the customer. Fig. 4 depicts the contributions of each load in the cost of the consumer before and after the selfscheduling. The simulation results show that in the base case and with the TOU tariff in the absence of the BEES system and PV panel, the cost of the consumer before and after the self-scheduling would be exactly the same as these values reported in [16].

2) SCENARIO 2
This scenario has been designed to compare the results obtained from the self-scheduling by using the SH-MPC model with those obtained in Scenario 1. Indeed, Scenario 1 corresponds to self-scheduling with deterministic energy price and load demand. As there is no uncertainty, the results obtained for the day-ahead scheduling with the TOU tariff marked as ''DA-TOU'' model in scenario 1 is expected to be the same as the ones derived for the SH-MPC model with the TOU tariff marked as ''SH-MPC-TOU'' model in terms of the cost. As mentioned before, the presented selfscheduling problem has been modeled as an MILP problem with multiple global optima. The simulation results obtained in this scenario would also verify this issue. Fig. 5 illustrates the schedules of controllable loads for the DA-TOU and SH-MPC-TOU cases. It is noteworthy that the operating costs of the two scenarios are the same and equal to $0.8709. As can be observed, the microwave oven is used at time slots 16 and 17 in the SH-MPC-TOU and DA-TOU cases, respectively, with the energy price of 0.02 $/kWh. Moreover, the results show that the best time slot to use the cooker oven is time slot 37 in the DA-TOU case while for the SH-MPC case, it is time slot 36. The electricity prices at time slots 36 and 37 are the same and equal to 0.04 $/kWh. The best time slots to use the spin dryer in the DA-TOU scenario are slots 26 and 27 while for the SH-MPC-TOU case, the best time slots are slots 25-26. The energy price during slots 25-27 is 0.04 $/kWh. Consequently, there is no difference in the costs of the customer in the mentioned scenarios.

3) SCENARIO 3
The SH-MPC model has been used in this scenario to enhance the self-scheduling of the residential consumer in the presence of the BEES system and PV panel. This scenario considers the TOU tariff and the only uncertain parameter of the problem is the solar power generation which its data are updated every 30 minutes for the whole day. The total energy generated by the solar PV panel is 31.479 kWh which is substantial compared to the total energy consumption of the consumer which is 39.01 kWh. Moreover, the BEES system is available to absorb the surplus solar power generation, charge during off-peak hours, and inject power into the system during peak hours. The simulation results indicate that in this case, the consumer not only does not purchase energy from the distribution company, but also gets profit by selling the surplus energy to the grid. The value of the objective function, in this case, is $-0.282713 showing the profit of the consumer by $0.282713. Fig. 6 illustrates the hourly amount of energy stored in the BEES system managed by the HEMS. The dotted line shows the real power stored in the BEES system. The scheduling of the appliances and the amount of energy stored in the BEES system are updated for the ahead time slots due to the variations of the solar power generation data updated every 30 minutes. It is noted that that the battery is charged at the maximum charging capacity during the final slots of the scheduling period to achieve the target value of energy available in the system at the end of the day while the amount of solar power generation is zero.
As expected, the battery injects power into the system and sells the surplus solar power generation to the grid during peak-load time slots to provide the consumer with a considerable profit. The results obtained for the power consumption in the base case, the case with load shifting, and also, the case with load shifting and the presence of the BEES system and PV panel are demonstrated in Fig. 7. As shown, load demands have successfully been shifted to off-peak time slots. It is worth mentioning that the net cost of fixed and controllable loads in this scenario is $0.8709 which is the same as those of scenarios 1 and 2.

B. SELF-SCHEDULING BASED ON RTP
In this section, three scenarios are considered to investigate the self-scheduling problem for all fixed and controllable loads while applying the RTP tariffs.

1) SCENARIO 4
This scenario investigates the self-scheduling problem for all fixed and controllable loads considering the RTP tariff. For the case without any load shifting, the cost of energy of the studied day is equal to $1.22093. The contributions of the fixed and controllable loads to the daily energy cost are $0.28343 and $0.9375, respectively. The total energy consumption of the prosumer is 39.01 kWh, similar to Scenario 1. The shares of the fixed and controllable loads are 9.96 kWh and 29.05 kWh, respectively. Applying this scenario, the electricity bill of the prosumer has declined to $1.08383. It is noteworthy that shifting the load demand of some appliances like the spin dryer, cooker oven, and vacuum cleaner would not impact the energy cost of the consumer. Fig. 8   the contribution of each load to the energy cost of the consumer before and after implementing the self-scheduling. The results obtained in this case also show that the energy costs of the consumer in the base case and with the RTP mechanism in the absence of the BEES system and solar PV panel before and after the demand-side management are just the same as the values reported in [ 16].

2) SCENARIO 5
In Scenario 5 similarly to Scenario 2, the self-scheduling problem is solved in a deterministic way with the RTP mechanism. As expected, the simulation results for this scenario show that the energy cost in this scenario is the same as Scenario 4. Fig. 9 illustrates the schedules of the controllable loads in the day ahead scheduling and RTP mechanism marked as ''DA-RTP'' case and the SH-MPC model with RTP mechanism marked as ''SH-MPC-RTP'' case.
The appliances with different schedules from that of Scenario 4 are the spin dryer, cooker oven, cooker hob, and vacuum cleaner. As Fig. 9 depicts, the vacuum cleaner is used at time slots 19 and 18 in the DA-RTP and SH-MPC-RTP cases, respectively. The energy tariffs at these two slots are the same and equal to 0.024 $/kWh. For the other three appliances, the usage times and the corresponding tariffs are  different. However, the electricity bills of the customer in the two scenarios are identical. Table 6 represents the schedules and costs of the mentioned appliances. As Table 6 indicates, the spin dryer, cooker hob, and cooker oven are different in terms of the schedules and RTP tariffs in Scenarios 4 and 5. However, the energy costs for all assets are the same, which in turn shows that this problem is associated with multiple global optima where the operating points are different for the studied scenarios. Fig. 9 depicts the scheduling of appliances.

3) SCENARIO 6
Similar to scenario 3, the self-scheduling problem is solved in the presence of the BEES and PV systems. The difference between scenarios 5 and 3 is the RTP mechanism used in Scenario 6 instead of the TOU mechanism. The forecasting data of the solar power generation are the same as those of scenario 3. In other words, the forecast is updated every 30 minutes and the SH-MPC model modifies the selfscheduling for the ahead time slots. It is noteworthy that the constraints relating to the permitted operating interval and interrupted operation of controllable loads have all been satisfied in this scenario. The total cost in this scenario is  equal to $0.050251, which is significantly reduced through efficiently utilizing 31.479 kWh solar power generation. It is worth noting that the primary cost of the consumer for this tariff has been $1.22093 while shifting the controllable loads has led to reducing the cost to $1.08383. Fig. 10 depicts the amount of energy stored in the BEES system which is managed by the HEMS. The performance of the BEES system at each time slot has also been shown while the dotted line indicates the real energy stored in the BEES system. As expected, the BEES system delivers power VOLUME 10, 2022 FIGURE 11. Power consumption data for (a) base case, (b) Shifted loads only, and (c) Shifted loads with PV and EES contributions.
to the system and sells surplus solar energy, and the stored energy during peak time intervals to give some benefits to the consumer. It is noteworthy that the constraint on the final value of the energy stored in the BEES system has been satisfied in this scenario as well. Fig. 11 indicates power consumption data for the base case, load shifting case, and also the case with load shifting with the BEES and PV systems. As can be observed, shifting the load demand to off-peak time slots has successfully been done to mitigate the cost. The net cost of controllable and fixed loads in this scenario is $1.08383 which is identical to those of scenarios 3 and 4.

VI. CONCLUSION
This paper presented a self-scheduling model for a HEMS, aimed at minimizing the electricity bill of a residential prosumer. The optimal operational decisions for using the controllable home appliances were updated using the SH-MPC model. The SH-MPC framework was developed to optimally operate the prosumer's assets over the day, which aimed at minimizing the daily electricity bill and optimizing energy use. To evaluate the effectiveness of the proposed algorithm, a number of scenarios were considered. The simulation results indicated that for the scenarios with deterministic load demand, the total cost was similar to the SH-MPC-based case. The performance of the proposed technique was also evaluated for the case with an uncertain solar irradiance forecast. As the MPC updates the scheduling according to the forecast of the uncertain parameter, i.e., solar power generation in this study, to minimize the daily electricity bill of the prosumer. Through the use of the presented framework, the running assets and fixed loads do not face any interruptions. The computational complexity of the problem was also alleviated by using an efficient MILP model. The presented problem was simulated using six scenarios where the first three scenarios addressed the TOU tariff and the remaining scenarios were devoted to the cases with the RTP mechanism. The electricity bill of the consumer without any load shifting, PV system, and BEES systems, would be $1.2874. The obtained results showed that for the first scenario investigating the day-ahead self-scheduling problem with the TOU tariff and without the PV and BEES systems, the total daily cost of the consumer was $0.8709. By using the SH-MPC model the electricity cost would be the same as the scenario 1 since there were no PV and BEES systems. This means that load shifting would help mitigate the daily cost of the prosumer by %32. The third scenario considered both the PV and BEES system in the self-scheduling problem using the SH-MPC model. As a result, the total operating cost would be $-0.282713, showing that the prosumer would be able to make a profit by selling power to the utility grid. For the RTP case without any load shifting program, the daily cost of the prosumer was $1.22093. Scenario 4 addressed the day-ahead scheduling problem with the RTP tariff without the PV and BEES systems. In this regard, the total daily operating cost without any load shifting program would be $1.08383. For Scenario 5 with the RTP mechanism and SH-MPC model without the PV and BEES systems, the result was the same as Scenario 4. The obtained results indicated that for the RTP case, the load shifting program could successfully mitigate the cost by 11%. In Scenario 6, the self-scheduling problem was solved using the RTP and SH-MPC model taking into account the PV and BEES systems. In this regard, the electricity cost reduced to $0.050251, showing 96% reduction in the cost in this case. The framework presented in this paper offers a potential strategy for prosumers to reduce operating costs and optimize electricity usage. Future research work will look at implementation condition monitoring strategies, such as long short term memories (LSTMs) and estimation theory, to predict prosumer electricity usage based on past performance and meteorological data.