Home Energy Management Systems with Branch-and-Bound Model-Based Predictive Control Techniques

: At a global level, buildings constitute one of the most signiﬁcant energy-consuming sectors. Current energy policies in the EU and the U.S. emphasize that buildings, particularly those in the residential sector, should employ renewable energy and storage and efﬁciently control the total energy system. In this work, we propose a Home Energy Management System (HEMS) by employing a Model-Based Predictive Control (MBPC) framework, implemented using a Branch-and-Bound (BAB) algorithm. We discuss the selection of different parameters, such as time-step, to employ prediction and control horizons and the effect of the weather in the system performance. We compare the economic performance of the proposed approach against a real PV-battery system existing in a household equipped with several IoT devices, concluding that savings larger than 30% can be obtained, whether on sunny or cloudy days. To the best of our knowledge, these are excellent values compared with existing solutions available in the literature.


Introduction
Over the last two decades the global electricity consumption market has been growing at an average yearly reported level of 3.1% [1], which causes extra stress on electrical power systems. Traditional grids will find it difficult to cope with this increasing demand, exacerbated by the integration of extensive variable energy resources, such as renewable energy systems. The grids tend to continuously extend their infrastructure, which is not sustainable for many different reasons. At a global level, buildings constitute one of the most significant energy-consuming sectors. In [1], it is mentioned that, according to the U.S. Energy Information Administration, the residential sector is expected to consume nearly 30% of the total electricity produced in the following decades. The residential sector is composed of buildings where families live. Typically, the occupants perform routine activities while they are at home, although these activities might change due to endogenous or exogeneous circumstances, such as, for instance, the recent pandemic. In Europe, nearly 75% of building floor area belongs to the residential sector [2]. This poses a challenge in terms of energy management. Most of the energy consumed in the residential building sector is scattered across many different buildings, each consuming a small amount of energy. Thus, the cost-effectiveness of energy efficiency measures in this sector is always much lower than in services buildings, which are generally used by many more people. In this context, it is of fundamental importance that the prevalence of the smart grid paradigm extends the impact capacity of the demand response.
In residential structures, efficient consumption control is critical. As a result, proper energy planning is also crucial for energy savings, which may be accomplished via effective energy consumption prediction models [3]. Home Energy Management Systems (HEMS) are essential for optimizing electricity use and obtaining energy savings. These systems depend on stochastic and complex dynamic aspects such as load usage and its costs. As a consequence, developing an effective control system for residential structures requires an accurate forecast procedure [4]. Real-time data analytics for load forecasting and supply, if renewable systems are employed, are critical for achieving a real-time demandsupply balance [5]. In this context, the current work addresses HEMS from a Model-Based Predictive Control (MBPC) perspective. The MBPC is an advanced method of control based on a receding horizon control, aimed at determining the best course of action while meeting the requirements.

Objectives, Contributions, and Work Organization
This article was developed considering the previously presented context and is the continuation of the authors research in the field. It has two objectives: (i) to develop a concise review of the state-of-the-art of background information and related recent publications, and, most importantly, (ii) to develop a sensitivity analysis of a model-based predictive control that integrates the HEMS system of a real case study and assess the best set of sampling time and prediction and control horizons.
The present article contributions are: • To provide a review of the most recent works related to the application of MBPC in residential HEMS incorporating photovoltaics and battery systems; • To provide a sensitivity analysis of MBPC for HEMS, considering the time step, prediction horizon (PH), and control horizon (CH) associated with the data. We show that a significant reduction in the MBPC time complexity with minimal impact on the performance can be obtained by employing a small CH, achieving substantial cost savings, or improved gains, in comparison with many of the approaches found in the literature.
The work is organized into five main sections. Section 1 introduces the context, objectives, and contributions. Section 2 presents a review of the state-of-the-art in home energy management systems, focusing on the use of model predictive control techniques in the residential sector. Section 3 presents the methodology, introducing descriptions of the case study, and of our proposed algorithm. Section 4 shows and discusses the results obtained. Section 5 presents the conclusions and future work.

State-of-the-Art
The state-of-the-art section is segmented into two main parts. The first part presents the background information, focusing on the concept and components of HEMS and its role in smart grids and computing trends; communication technologies; demand response; and load scheduling techniques, and the use of MBPC in HEMS. The second part presents recent related works in a descriptive and qualitative review and the challenges and future research opportunities.

Background Information
In [6], an extensive review is presented, considering the use of EMS in buildings. Energy management is the set of activities that contribute to saving energy. Energy management activities are organized according to an Energy Management Program that describes the activities and is usually supported by IT systems known as Energy Management Systems (EMS). There are four main classes of activities in the scope of the EMS: (i) data acquisition, storage, processing, analysis, and reporting; (ii) control; (iii) diagnosis; and (iv) optimization. Data acquisition, storage, analysis, and reporting describes the activities related to collecting and processing data from different types of sensors, such as power meters or weather stations. These data can be used to monitor and evaluate the operation of the building and identify mismatches between the models in order to calibrate them or identify energy efficiency actions. The objective of the control, diagnosis, and optimization of As described in [1], demand response systems have evolved to use distributed energy generation and energy storage. Although home energy management is overall an excellent initiative, local energy use decisions can have an adverse effect on the main grid. For example, phenomena such as "rebound peak," where too many appliances are shifted to times with low prices, can cause new and unexpected demand peaks. Thus, from the utility's perspective, it is preferable to manage DR at the neighborhood level. This gives rise to the need for HEMS coordination across households. The entities involved in smart HEMS coordination include: (i) The utility operator responsible for reliable electricity transmission to the end-customer. Utilities benefit from DR by managing demand and promoting energy efficiency; (ii) The aggregator, who can provide DR services to the utility and ancillary services to end-users on behalf of the utility and can become the focal point for energy trading; (iii) End users, who can take the role of energy "prosumers" by operating distributed energy and energy storage devices. Energy-management coordination across households can be centralized or decentralized. In a centralized setting, one entity is responsible for managing energy demand in a group of homes. In decentralized coordination, the end-users exert more control over overload scheduling choices.
The implementation of energy efficiency and demand response measures requires that consumer loads be either reduced or shifted. Load shifting involves scheduling to find the optimal operational timings to operate consumer appliances, considering both peak demand times and user preferences. For load shifting, several choices need to be considered to find an optimal schedule. This schedule will always be an approximation as future electricity demand and generation cannot be predicted with absolute certainty. In the literature, different mathematical optimization techniques are used to find optimal load shifting schedules. Constrained-based mathematical optimization techniques have been used extensively for device scheduling. Linear, nonlinear, and convex programming are examples of constrained-based optimization techniques. Linear and nonlinear programming models compute the relationships across variables as a linear and nonlinear function, respectively, according to the distribution of the reference data. Nonlinear programming is computationally more expensive. Convex programming is a superset of linear programming and involves relations and convex objective functions. In [1], a concise description of used techniques is provided, hereby summarized in Table 1. Table 1. Description of scheduling techniques [1].

Technique Description
Linear Programming (LP) Models' relationship between variables as linear to maximize or minimize an objective.

MILP
Similar to LP; however, additional constraints are put on at least one decision variable so that they have to be discrete.

Convex Programming
Minimizes a convex or maximizes a concave objective function.
Genetic Programming A heuristic search method inspired by biology and iteratively produces "fitter" candidates using "crossover" and "mutation" functions.
Particle Swarm Optimization A heuristic search that iteratively produces better candidates using "position", "velocity", and "fitness" values Model Predictive Control Uses a model to predict plant/required output. It chooses a "control action" by repeatedly solving an online optimization problem.
Game Theory Models the iteration between different "players" and the environment using fixed rules.
Artificial Neural Networks (ANN) A modelling techniques using artificial neurons to create complex models for forecasting and classification.
Fuzzy Logic Control (FLC) Uses a rule-based system to produce an output for forecasting or classification.

Reinforcement Learning
A machine learning methodology that learns how to maximize a reward function through trial and error.

Related Works
The Clarivate Analytics Web-of-Science was the source of information used to appraise the state-of-the-art works related to the topic of this article. Figure 1 presents the survey method and rationale used for the systematic review. The eligibility criteria and study selection are based on the accordance of the published material within the search terms, the period, the relevance of the field to this work, the keywords and abstract pertinent to the current topics, and consideration through the screening of appropriate content throughout the text. The selection of topics under review is justified by the interest of the research community, as well as the need for practical implementations of efficient control of residential houses provided with PV and storage. Among the different methods to achieve this, Model-Based Predictive Control techniques have emerged as very promising solutions, which is why the search will be focused on this class of method. Figure 1 also presents the number of publications filtered through the adopted survey methodology. Fuzzy Logic Control (FLC) Uses a rule-based system to produce an output for forecasting or classification.

Reinforcement Learning
A machine learning methodology that learns how to maximize a reward function through trial and error.

Related Works
The Clarivate Analytics Web-of-Science was the source of information used to appraise the state-of-the-art works related to the topic of this article. Figure 1 presents the survey method and rationale used for the systematic review. The eligibility criteria and study selection are based on the accordance of the published material within the search terms, the period, the relevance of the field to this work, the keywords and abstract pertinent to the current topics, and consideration through the screening of appropriate content throughout the text. The selection of topics under review is justified by the interest of the research community, as well as the need for practical implementations of efficient control of residential houses provided with PV and storage. Among the different methods to achieve this, Model-Based Predictive Control techniques have emerged as very promising solutions, which is why the search will be focused on this class of method. Figure 1 also presents the number of publications filtered through the adopted survey methodology. As can be seen at the bottom-right box of Figure 1, a sample of 23 scientific articles was considered as representative related works. The works will be briefly described here, and their more detailed classification is presented in Table 1.
The uncertainty feature has been associated with models in many recent publications. In [14], authors perform energy management in a predictive fashion, relying on machine learning for residential hybrid energy systems, considering a photovoltaic system, battery bank system, and residence demand. The models created develop a one-step-ahead of energy produced and electric load, using a sliding window in a multi-objective fashion focusing on battery state-of-the-art, reduction of dependence on grid energy, and the reduction of carbon emissions. The coefficient of determination achieved in their predictors was between 93.08% and 97.25%. In [15], the authors develop a scenario-based stochastic MBPC, using as a case study a research villa equipped with storage and renewable energy production. They compute the covariance matrix that constrains time-dependent information and use it to auto-correlate scenarios from the probabilistic forecasts that serve as inputs to an EMS system that considers uncertainty. In [16], a residential HEMS is implemented based on an expectation-oriented stochastic model for the battery scheduling to cope with the uncertainty related to supply and demand.
Energy pricing and sensitivity to tariffs are also frequently found features. In [17], a dynamic energy management system connected a residential application to a microgrid. A photovoltaic grid-tied system and a storage model were optimally designed using a As can be seen at the bottom-right box of Figure 1, a sample of 23 scientific articles was considered as representative related works. The works will be briefly described here, and their more detailed classification is presented in Table 1.
The uncertainty feature has been associated with models in many recent publications. In [14], authors perform energy management in a predictive fashion, relying on machine learning for residential hybrid energy systems, considering a photovoltaic system, battery bank system, and residence demand. The models created develop a one-step-ahead of energy produced and electric load, using a sliding window in a multi-objective fashion focusing on battery state-of-the-art, reduction of dependence on grid energy, and the reduction of carbon emissions. The coefficient of determination achieved in their predictors was between 93.08% and 97.25%. In [15], the authors develop a scenario-based stochastic MBPC, using as a case study a research villa equipped with storage and renewable energy production. They compute the covariance matrix that constrains time-dependent information and use it to auto-correlate scenarios from the probabilistic forecasts that serve as inputs to an EMS system that considers uncertainty. In [16], a residential HEMS is implemented based on an expectation-oriented stochastic model for the battery scheduling to cope with the uncertainty related to supply and demand.
Energy pricing and sensitivity to tariffs are also frequently found features. In [17], a dynamic energy management system connected a residential application to a microgrid. A photovoltaic grid-tied system and a storage model were optimally designed using a demand response framework, responding to energy pricing to schedule the energy flows. They used two linear models (open and closed loop) and a quadratic approach based on model predictive control, and the performance of the dynamic model was validated with experimental data and an intelligent metering system. In [18], a building was modelled with a modulating air-sourced heat pump, a photovoltaic system, a battery, and thermal storage systems for floor heating and hot-water supply. A rolling horizon approach was used to obtain an optimal solution by a mixedinteger linear model in less than 1 min. An important conclusion from this work is that the authors determined that a typical horizon of 24 h for prediction and control results in unintended, but avoidable, end-of-horizon effects. They concluded that the common objective of maximizing self-consumption is not always economically viable, and it is dependent on the applicable tariffs.
In [19], an expectation-oriented stochastic model for optimal residential EMS is proposed. It aims to allow the battery to cope with the uncertainty of electricity supply and demand. The battery scheduling mechanism is proposed in an intraday energy storage management fashion, and the results validated the convexity of the method. In [20], the benefits of implementing the MBPC for a residential EMS are evaluated. The system was composed of the building demand, PV system, and battery storage. It considered the time-of-use, tariffs, variable sizes of PV systems, and battery life-cycle costs. The model was compared with a rule-based controller and tested in ten residences.
In [21], the scheduling of battery and heat pump was explored in the EMS context via model-free reinforcement learning techniques. The algorithm was tested in a multi-agent collaborative and single-agent stochastic microgrid setting. The results were assessed in terms of obtained improvements in the PV self-consumption. In [22], optimizing EMS was used to coordinate a group of residential buildings in a high degree of self-sufficiency, with the introduction of financial incentives. The local EMS of individual PV battery systems uses an MBPC based on deterministic dynamic programming to minimize the individual economic costs and grid electricity demand peaks. The performance is then compared with uncoordinated systems among the group of buildings.
Another finding in our survey is that residential EMS are increasingly being adapted regarding the integration of electric vehicles (EV). In [23], the HEMS integrates a plug-in EV, a photovoltaic array, and a heat pump. The objective of the implemented stochastic MBPC was to minimize the total electricity costs while reducing the battery degradation of the vehicle. In [24], the authors focused on an MBPC for a prosumer-centric networked microgrid, with individual EMS in each residence to determine the battery and EV battery scheduling. They aimed to reduce residential customer's operation costs and improve overall savings, obtaining reductions on the peak load and power losses.
In [25], a complex MBPC for EMS in residential buildings is investigated from an economic point of view. The system includes PV, battery storage, thermal storage, and HVAC. Their results achieved an 11.6% cost reduction compared with the reference model and increased PV self-consumption. Additionally, from an economic point of view, in [26], for a battery scheduling issue, a dissipative-based economic distribution MBPC is developed. The proposed approach is scalable as it does not require online iterative optimizations across the controller network. In [7], a novel method for leveraging receding horizon control strategies for distributed battery storage is developed. Authors aimed to maximize PV use and minimize battery degradation in a residential case while complying with the grid's constraints. The present work highlights the results obtained in [7]: longer prediction horizons lead to better storage placement strategies and higher computational complexity that can quickly become computationally prohibitive.
In [27], the authors explore economic MBPC to optimize, in a HEMS, hybrid PVbattery systems to address grid scheduled blackouts. They aim to cover the load as much as possible while minimizing the costs of the energy consumed and improving the lifetime of the storage. In [28], a new combined control algorithm is proposed; a high-level MBPC based on a mixed-integer linear programming problem is combined with an additional low-level, rule-based controller. In [29], the authors jointly optimize the capacity and location of dispatchable and non-dispatchable distributed generating units and battery storage systems employed in a stand-alone residence with an EV charging load. In [30], the authors introduce a user-driven microgrid power market, in which the EMS deals with possible pricing schemes through the use of a dissipative-based distributed economic MBPC. A simulation study with photovoltaic energy generation and Vanadium Redox batteries is presented to illustrate the efficacy of the proposed method. In this approach, the authors add to the MBPC the occupant's behavior in each device control in HEMS. Their results show that, in real-time five minute pricing, these methods can achieve 20-30% cost savings in different appliances and 42% savings in overall electricity cost adding battery optimal control when compared to the traditional rule-based control.
In [31], a model for optimal sizing design and real-time operation is developed, considering thermal and electrical energy storage systems in residences equipped with a PV system and HVAC. The model was developed using particle swarm optimization to minimize daily electricity and life cycle costs in an intelligent building context. The authors developed an MBPC to reduce the expenses of electricity to the end-user via storage schedule. Their MBPC allowed an annual cost reduction of 80% in electricity (from USD 1445.40 to USD 436.20 with battery, and USD 282.70 with battery and thermal storage), with over 42% in the life cycle cost. In [32], a centralized residential MBPC is developed, aimed at occupant comfort and energy management, including photovoltaics and a stationary battery unit in a bidirectional grid system with variable cost rates and tariffs. They obtained a reduction of 13% in the energy cost with the proposed approach compared to rule-based energy management. In [33], a user-centric EMS is developed with a multi-objective MBPC framework that focuses on reducing energy costs and carbon emissions, improving thermal comfort and appliance user convenience. The work was developed based on machine learning methods to derive data-driven appliance models and usage patterns from predicting the home's future energy consumption. They generated 7.6% in whole-home energy savings.
In [34], the potential of MBPC in detached residences' EMS is assessed. The residence systems being used have HVAC systems, photovoltaics, and battery systems. The model used a successive series of six measurements of 120 h each within the heating season. When focusing on HVAC (heat pump), they obtained an average increase in the coefficient of performance of 22.2% and an average increase of 234.8% in terms of photovoltaic selfconsumption. The operational costs for the HVAC were also evaluated, and a reduction of 34.0% was obtained when using the MBPC.
Thus, from the literature review concerning the MBPC application in HEMS, the use of scenario-based MBPC analysis stands out. The included studies considered different tariffs and objectives, for example, maximization of the profits or minimization of grid dependence. Most addressed the EMS MBPC in a demand response scenario considering individual buildings, but some of the studies focused on the central control of a group of residential buildings. Some of the studies considered the integration of electric vehicles as well as the system's battery or a supplementary battery and respective arbitrage. Focusing on the studies that had as an objective the reduction of the net cost of electricity, results varied from 7.6% to 80% among different publications. The savings are not, indeed, as straightforward to compare between different studies, as photovoltaic generation heavily depends on the solar irradiation availability, and the battery management also depends on the demand profile of the building.

Methodology
This section presents the case study used in this work, demonstrates some interesting variables for this work, and introduces the mathematical formulation of the proposed HEMS MBPC.

Case Study
The present work is integrated in a broader Portuguese project, "NILMforIHEM", which aims to (i) develop intelligent algorithms for electrical load disaggregation, with measured data in a highly monitored residential dwelling, and (ii) perform the optimization of the energy management system, considering simultaneously the demand, the generation through photovoltaic panels, storage through batteries, and energy from the grid.
The case study is composed of a residential building located in Faro, south of Portugal. It is a typical residential building but equipped with an IoT data acquisition and control platform that enables its usage in several energy research projects. The building comprises twenty spaces, and a very detailed description may be found in [35,36]. Several electrical appliances are used in the building, typically employed within the residential building typology. Their consumption over time is discussed in [37]. An acquisition system was implemented to monitor different electric variables measured by different sensors and smart meters installed in the building, among them smart meters for every circuit breaker, for the electric consumption of the whole building, and for the inverter. Gateways and a technical network are responsible for the data transmission from/to the measurement devices. Nearly 300 variables are sampled every second or every minute and made available by the IoT platform. As the measurement devices are not synchronized, some pre-processing is required to have a common time base among the used variables.
Foremost of crucial importance for this work is the description of the photovoltaic and storage systems. The building's energy system is composed of a photovoltaic installation consisting of 20 Sharp NU-AK panels with a maximum power of 300 W each, organized in two strings. A Kostal Plenticore Plus Inverter is used, with a storage capacity of 11.5 kWh using a BYD Battery Box HV H11.5. The variables related to this equipment are sampled with a one-minute interval. The inverter has a proprietary system that manages the energy from the PV and battery, and the experimental results shown throughout the paper are a result of the operation of this proprietary system. Also noteworthy is that the building has one intelligent weather station (described in detail in [38]). This device measures the variables of air temperature, relative humidity, and global solar radiation, and it also predicts their evolution in time within a self-defined prediction horizon (details on the forecast methods are presented in [38]).
The variables associated with the electricity produced by the PV system are obtained by a Kostal smart meter. The house consumption data is obtained by a Carlo Gavazzi (EM340) 3 phase energy meter. Figure 2 presents the view of the building's PV system [39]: (a,b) photovoltaic panels, (c) inverter, (d) battery. The present work is integrated in a broader Portuguese project, "NILMforIHEM", which aims to (i) develop intelligent algorithms for electrical load disaggregation, with measured data in a highly monitored residential dwelling, and (ii) perform the optimization of the energy management system, considering simultaneously the demand, the generation through photovoltaic panels, storage through batteries, and energy from the grid.
The case study is composed of a residential building located in Faro, south of Portugal. It is a typical residential building but equipped with an IoT data acquisition and control platform that enables its usage in several energy research projects. The building comprises twenty spaces, and a very detailed description may be found in [35,36]. Several electrical appliances are used in the building, typically employed within the residential building typology. Their consumption over time is discussed in [37]. An acquisition system was implemented to monitor different electric variables measured by different sensors and smart meters installed in the building, among them smart meters for every circuit breaker, for the electric consumption of the whole building, and for the inverter. Gateways and a technical network are responsible for the data transmission from/to the measurement devices. Nearly 300 variables are sampled every second or every minute and made available by the IoT platform. As the measurement devices are not synchronized, some pre-processing is required to have a common time base among the used variables.
Foremost of crucial importance for this work is the description of the photovoltaic and storage systems. The building's energy system is composed of a photovoltaic installation consisting of 20 Sharp NU-AK panels with a maximum power of 300 W each, organized in two strings. A Kostal Plenticore Plus Inverter is used, with a storage capacity of 11.5 kWh using a BYD Battery Box HV H11.5. The variables related to this equipment are sampled with a one-minute interval. The inverter has a proprietary system that manages the energy from the PV and battery, and the experimental results shown throughout the paper are a result of the operation of this proprietary system. Also noteworthy is that the building has one intelligent weather station (described in detail in [38]). This device measures the variables of air temperature, relative humidity, and global solar radiation, and it also predicts their evolution in time within a self-defined prediction horizon (details on the forecast methods are presented in [38]).
The variables associated with the electricity produced by the PV system are obtained by a Kostal smart meter. The house consumption data is obtained by a Carlo Gavazzi (EM340) 3 phase energy meter. Figure 2 presents the view of the building's PV system [39]: (a,b) photovoltaic panels, (c) inverter, (d) battery.

Household Power Demand and PV Production Profile
One year of data, from May 2020 to April 2021 was collected, processed, and will be used in this work. The weather information within this period can be seen in  Either due to acquisition problems or sensor faults in a few periods throughout the year, valid data was not simultaneously available for all the variables used in this work. Due to this, data for these periods was deleted, as it can be seen in the subsequent figures, before and after January 2021.

Household Power Demand and PV Production Profile
One year of data, from May 2020 to April 2021 was collected, processed, and will be used in this work. The weather information within this period can be seen in  Either due to acquisition problems or sensor faults in a few periods throughout the year, valid data was not simultaneously available for all the variables used in this work. Due to this, data for these periods was deleted, as it can be seen in the subsequent figures, before and after January 2021.

Household Power Demand and PV Production Profile
One year of data, from May 2020 to April 2021 was collected, processed, and will be used in this work. The weather information within this period can be seen in  Either due to acquisition problems or sensor faults in a few periods throughout the year, valid data was not simultaneously available for all the variables used in this work. Due to this, data for these periods was deleted, as it can be seen in the subsequent figures, before and after January 2021.   The annual energy consumption is shown in Figure 6. As expected, more energy is consumed in the winter, due to heating requirements. Air conditioning is sometimes used during the summer, but its operation is occasional and is not so relevant in terms of con-  The annual energy consumption is shown in Figure 6. As expected, more energy is consumed in the winter, due to heating requirements. Air conditioning is sometimes used during the summer, but its operation is occasional and is not so relevant in terms of consumption. Figure 5. Maximum, mean, and minimum annual air relative humidity. The annual energy consumption is shown in Figure 6. As expected, more energy is consumed in the winter, due to heating requirements. Air conditioning is sometimes used during the summer, but its operation is occasional and is not so relevant in terms of consumption. During the yearly period, approximately 10 MWh were consumed in the residence. The following two figures show the power injected into the grid (Figure 7) and bought from the grid ( Figure 8). As can be seen, the house is a nearly zero annual energy building but unfortunately, due to the tariffs, that is not translated into economic costs.
As it can be seen, except in the winter period, a large amount of energy was supplied to the grid. During the yearly period, approximately 10 MWh were consumed in the residence. The following two figures show the power injected into the grid (Figure 7) and bought from the grid ( Figure 8). As can be seen, the house is a nearly zero annual energy building but unfortunately, due to the tariffs, that is not translated into economic costs.
As it can be seen, except in the winter period, a large amount of energy was supplied to the grid.   Over most of the year, except in the winter months, the house is self-sufficient. The degree of self-sufficiency of the residence is 0.67, and its self-consumption rate is 0.75, as it can be seen in Figure 9.
(a) (b) Figure 9. (a) Self-sufficiency rate. (b) Self-consumption rate. Over most of the year, except in the winter months, the house is self-sufficient. The degree of self-sufficiency of the residence is 0.67, and its self-consumption rate is 0.75, as it can be seen in Figure 9.  Over most of the year, except in the winter months, the house is self-sufficient. The degree of self-sufficiency of the residence is 0.67, and its self-consumption rate is 0.75, as it can be seen in Figure 9.

Formulation of MBPC
Model-based predictive control [40] is a general control engineering framework in which the controllers employ predictive plant models to obtain predictions of the future system behavior. These models are the basis for computing future control actions by minimization of a pre-defined objective function. The general principle of MBPC is illustrated in Figure 10. The controller uses past input/output system data and predictions of the future system behavior to compute the future control actions that minimize a specified cost function. Using this principle, several approaches have been proposed that differ mainly in the type of predictive plant models, the strategy to find the sequence of future control actions, the cost function employed, and the way constraints are handled. system behavior. These models are the basis for computing future control actions by minimization of a pre-defined objective function. The general principle of MBPC is illustrated in Figure 10. The controller uses past input/output system data and predictions of the future system behavior to compute the future control actions that minimize a specified cost function. Using this principle, several approaches have been proposed that differ mainly in the type of predictive plant models, the strategy to find the sequence of future control actions, the cost function employed, and the way constraints are handled. Figure 10. Model-based predictive control strategy [41].
As already described, the HEMS system is composed of the main grid, the photovoltaic system, the storage system, and the home load. The grid connection is bidirectional, which allows it to inject excess energy into the grid.
The power balance of the system is given by Equation (1), where PPV is the power produced by the PV system, G P → is the power supplied by the grid, B P → is the battery charging power, B P → is the battery discharging power, PH is the home power consumption, and G P → is the power injected into the grid.
MBPC will control the charge/discharge states of the battery. Notice that the battery can only be charged by the PV, not from the grid. The two control signals are therefore binary variables, indicating if it can be charged,  Figure 10. Model-based predictive control strategy [41].
As already described, the HEMS system is composed of the main grid, the photovoltaic system, the storage system, and the home load. The grid connection is bidirectional, which allows it to inject excess energy into the grid.
The power balance of the system is given by Equation (1), where P PV is the power produced by the PV system, P G→ is the power supplied by the grid, P →B is the battery charging power, P B→ is the battery discharging power, P H is the home power consumption, and P →G is the power injected into the grid.
MBPC will control the charge/discharge states of the battery. Notice that the battery can only be charged by the PV, not from the grid. The two control signals are therefore binary variables, indicating if it can be charged, C →B = 1, or not, C →B = 0; or discharged, C B→ = 1, or not, C B→ = 0. The combination C →B = 1; C B→ = 1 is invalid.
The MBPC problem can then be formulated as: where k is the index of the sample, belonging to the interval [k start , k end ], PH is the Prediction Horizon, and J[i] is our cost function at sample i. Here, an economic cost function will be employed, given as: Energies 2021, 14, 5852 13 of 26 P →G ≤ P →G MAX (8) P PV→H , P →B , P PV→G , P B→ , P PV , P →G , P G→ , P H ≥ 0 (9) In the above equations, E B [i] represents the actual energy in the battery and E B MAX represents its maximum. SOC is the battery state of charge, which should lie between a minimum (SOC min ) and a maximum (SOC Max ). P →B Max and P B→ Max denote the maxima values of battery charging and discharging powers, P →G MAX is the maximum power injected to the grid, and P PV→H and P PV→G denote the power generated by the PV injected into the house and the grid, respectively.
The equality restrictions are: In these two last equations, P B→G [i] and P B→H [i] are the power discharged from the battery into the grid and into the house, respectively.
The update equations are: The solution of problem (2) is a sequence of control actions, U, where only the first will be applied to the system. In the next instant, (2) is solved again, with new values, and the process continues.

The Branch-and-Bound Algorithm
One approach to non-linear MBPC, which has been the subject of more recent research and has already been successfully applied to some control problems, consists of discretizing the control space into an appropriate finite size set of control actions and performing a search for the optimal future control trajectory within the available set of control options. In this case, the non-linear MBPC optimization problem is formulated as a search problem in the discretized control space and may be solved using discrete optimization methods. Branch-and-Bound (BaB) methods have been proposed [42] and applied in practice to this type of discrete (or discretized) non-linear MBPC problem (for examples of this practice, see [43,44]).
BaB methods are structured search techniques, belonging to a general class of enumerative schemes, commonly used to solve complex discrete optimization and combinatorial programming problems by dividing them into smaller subproblems using a tree structure. The choice of an adequate control action at every instant of the prediction horizon constitutes the various sub problems to be solved. Figure 11 illustrates the tree structure imposed by the BaB method when applied to a discrete MBPC problem having a prediction horizon PH and a control horizon CH. merative schemes, commonly used to solve complex discrete optimization and combinatorial programming problems by dividing them into smaller subproblems using a tree structure. The choice of an adequate control action at every instant of the prediction horizon constitutes the various sub problems to be solved. Figure 11 illustrates the tree structure imposed by the BaB method when applied to a discrete MBPC problem having a prediction horizon PH and a control horizon CH. Figure 11. Branch-and-bound tree structure for model-based predictive control [41].
Assume A is a (nao × NA) matrix of nao possible combinations of control actions for the NA actuators considered. The notation Ai represents the i th possible combination of actions and corresponds to row i in matrix A. Notice that, in our application case, only three control combinations are available.
At the initial step of the optimization, in time instant k, the BaB method creates the initial tree node corresponding to the decision of which action should be taken at that time step. As nao control combinations are available, the corresponding number of branches is created by computing the predicted system output, [ ]  J k + , is evaluated. In the next prediction step, for k +1, the process is repeated for the nodes created in each branch resulting from the previous step, creating nao 2 new branches. The whole process is repeated until time instant k + PH − 1 is reached, where the number of created branches is nao PH . The exponential nature of the whole process is clear, and even for a small number of control options and not too large prediction horizons, the number of available solutions quickly becomes prohibitively large. The optimal solution is chosen by selecting the control trajectory that minimizes (2).
To reduce the number of solutions enumerated, two approaches are taken: the use of bounds to restrict branching and performing the search over a control horizon (CH). As formulated in [42], two bounds are employed: • an upper bound on the total cost from instant k + 1 to k + PH; • and a lower bound on the cost from instant k + i to k + PH. Figure 11. Branch-and-bound tree structure for model-based predictive control [41].
Assume A is a (nao × NA) matrix of nao possible combinations of control actions for the NA actuators considered. The notation A i represents the i th possible combination of actions and corresponds to row i in matrix A. Notice that, in our application case, only three control combinations are available.
At the initial step of the optimization, in time instant k, the BaB method creates the initial tree node corresponding to the decision of which action should be taken at that time step. As nao control combinations are available, the corresponding number of branches is created by computing the predicted system output,ŷ[k + 1], and for each branch the cost function, J[k + 1], is evaluated. In the next prediction step, for k +1, the process is repeated for the nodes created in each branch resulting from the previous step, creating nao 2 new branches. The whole process is repeated until time instant k + PH − 1 is reached, where the number of created branches is nao PH . The exponential nature of the whole process is clear, and even for a small number of control options and not too large prediction horizons, the number of available solutions quickly becomes prohibitively large. The optimal solution is chosen by selecting the control trajectory that minimizes (2).
To reduce the number of solutions enumerated, two approaches are taken: the use of bounds to restrict branching and performing the search over a control horizon (CH). As formulated in [42], two bounds are employed: • an upper bound on the total cost from instant k + 1 to k + PH; • and a lower bound on the cost from instant k + i to k + PH.
At time step i in the optimization, a branch is followed only if the cumulative cost from step 1 to step i − 1, J 1:i−1 [k], plus the lower bound on the cost from i to PH,Ĵ i:PH [k], is smaller than the upper bound on the total cost,Ĵ 1:PH [k]. Thus, the branching rule is given by: This rule may be further decomposed by noting that its second term on the left-hand side of the condition equals the cost of using a control profile A j at step i, plus the estimated cost from step i + 1 to PH: when the rule does not hold, the branch is not followed because it does not contain an optimal solution, thus pruning all the tree nodes that would be created from the current node. In the typical formulation, branching is only performed until the control horizon is reached and it is suggested that a constant control combination should be applied successively to the system model until the prediction horizon is reached. In our actual application, the PV system control, only three branches exist in each node. At each time instant k, before the minimization problem is solved by the BaB method, the upper bound on the cumulative cost is computed by successively minimizingĴ[i] from i = 1 to i = PH: (17) This value, also called the incumbent value, is the initial estimate of the minimum of When the BaB algorithm is in one node at level i < CH, and it must decide if a particular branch j should be searched in more depth or not, the estimate of the lower bound on the cumulative cost from step i to PH, J L i:PH [k], must be computed. This can be computed as: Notice that the logic control action for i > CH is simply not using the battery, which means that the second term in the r.h.s. of (20) can be simply estimated as: An accurate lower bound estimate of the 1st term in the r.h.s. of (20) is very hard to achieve and it is preferable to make it implicitly zero in Equation (20) to prevent the search from not exploring parts of the tree, which may contain the optimal solution due to a bad estimate. If is larger than the incumbent, then there is no need to search the current branch as no better solution will be found. When i = CH, this value is compared with the current incumbent, updating it if a smaller value is found.

Model-Based Predictive Control Analysis
The method employed to perform sensitivity analysis is exhaustively described in [45,46]. This work developed two sensitivity analyses concerning the control and prediction horizons. The whole of these elements in an MBPC is described in [47]. The first analysis (Analysis 1) is focused on determining the impact of the prediction horizon (here considering the control horizon equal to prediction horizon) and time step between the samples on the power fluxes determined by the MBPC as well as the computational time. The importance of the prediction horizon in predictive control modelling is explained further in [48]. The second analysis (Analysis 2) is focused on determining the impact of the control horizon on the costs of the system.

Analysis 1-Prediction Horizon and Time Step Sensitivity Analysis
In Analysis 1, 18 scenarios resulted from the combination of three main parameters: (i) weather conditions, through the selection of a sunny day (29 May 2020) and a cloudy day (13 May 2020); (ii) Time steps between samples of 5, 10, and 15 min; (iii) prediction horizons of 12, 24, and 36 steps ahead. Further details are presented in the results section. Table 2 presents the description of the different scenarios for the first analysis. All simulations were performed in Matlab R2021a, in an ASUS hybrid portable, with an Intel i7-8550U CPU @ 1.80 GHz, 8 GB of RAM, and 4 physical cores, running windows 10 Home Edition.
All scenarios considered a complete first day, and 15 h of the second day, as the largest prediction horizon, in hours, is 36/4 = 9 h. Therefore, the same time duration was considered for all scenarios.
The last column presents the computational time of the MBPC applied to all the data sequence. Although definitive quantitative conclusions should not be taken, as several times two parallel Matlab sessions were executed simultaneously, some qualitative conclusions can be drawn: In general, computational time varies with the type of day, with faster executions for sunny days. For the same time step, computational time increases with prediction horizon, although not linearly. For the same prediction horizon, computational time decreases with the time step, as the number of samples within the considered period is inversely proportional to the time step.
In all simulations, the following parameters were used: SOC min = 0.05, SOC Max = 1.0, E B MAX = 11.2 kWh, P →B Max = P B→ Max = P →G MAX = 5.5 kW For the Portuguese Electricity Company (EDP), five different types of tariffs are available for the residential market. We use the tariff employed in the residence, which is a daily dual tariff. In the normal period (08:00 to 22:00) a price of 0.1863 EUR/kWh is employed, a value of 0.0934 EUR/kWh being applied in the economic period (22:00 to 08:00). In terms of the buying cost, a value equal to 90% of the hourly intraday OMIE market is employed.
We shall first use S1 for an illustration of the proprietary system performance vs. the MBPC simulation. Figure 12 illustrates the PV power and the house consumption during the period under consideration.
(08:00 to 22:00) a price of 0.1863 EUR/kWh is employed, a value of 0.0934 EUR/kWh being applied in the economic period (22:00 to 08:00). In terms of the buying cost, a value equal to 90% of the hourly intraday OMIE market is employed.
We shall first use S1 for an illustration of the proprietary system performance vs. the MBPC simulation. Figure 12 illustrates the PV power and the house consumption during the period under consideration. As it can be seen, on 13 May, after 11:00, we have a very cloudy day, and the house power demand is much larger than the PV-generated power. Despite that, as the proprietary control is myopic (it does not look ahead into the future), it discharges much more of the battery than the MBPC, as can be seen in Figure 13. Please note that negative values charge the battery, while positive values denote charging. As it can be seen, on 13 May, after 11:00, we have a very cloudy day, and the house power demand is much larger than the PV-generated power. Despite that, as the proprietary control is myopic (it does not look ahead into the future), it discharges much more of the battery than the MBPC, as can be seen in Figure 13. Please note that negative values charge the battery, while positive values denote charging.
(08:00 to 22:00) a price of 0.1863 EUR/kWh is employed, a value of 0.0934 EUR/kWh being applied in the economic period (22:00 to 08:00). In terms of the buying cost, a value equal to 90% of the hourly intraday OMIE market is employed.
We shall first use S1 for an illustration of the proprietary system performance vs. the MBPC simulation. Figure 12 illustrates the PV power and the house consumption during the period under consideration. As it can be seen, on 13 May, after 11:00, we have a very cloudy day, and the house power demand is much larger than the PV-generated power. Despite that, as the proprietary control is myopic (it does not look ahead into the future), it discharges much more of the battery than the MBPC, as can be seen in Figure 13. Please note that negative values charge the battery, while positive values denote charging. Consequently, the BSC is higher in the case of MBPC, while it is exhausted during several periods of the 13 May ( Figure 14). Consequently, the BSC is higher in the case of MBPC, while it is exhausted during several periods of the 13 May ( Figure 14). Due to the different control algorithms, the power profiles extracted from the grid and exported to the grid are the ones shown in Figure 15. Visually, we can verify that the actual system must import energy from the grid during most of the 13 May, exporting energy whenever it can (at a much lower price).
A summary of the evolution of the signals described before can be found in the next figures, with the first one using the experimental data ( Figure 16) and the next one the MBPC (Figure 17). Due to the different control algorithms, the power profiles extracted from the grid and exported to the grid are the ones shown in Figure 15. Consequently, the BSC is higher in the case of MBPC, while it is exhausted during several periods of the 13 May ( Figure 14). Due to the different control algorithms, the power profiles extracted from the grid and exported to the grid are the ones shown in Figure 15. Visually, we can verify that the actual system must import energy from the grid during most of the 13 May, exporting energy whenever it can (at a much lower price).
A summary of the evolution of the signals described before can be found in the next figures, with the first one using the experimental data ( Figure 16) and the next one the MBPC (Figure 17). Visually, we can verify that the actual system must import energy from the grid during most of the 13 May, exporting energy whenever it can (at a much lower price).
A summary of the evolution of the signals described before can be found in the next figures, with the first one using the experimental data ( Figure 16) and the next one the MBPC (Figure 17).   Notice that, in the last figure, the values of 1, 2, and 3 of the Actions signal denote discharging, maintaining, and charging the battery, respectively.
The situation of a sunny day is very different from the one shown previously. To illustrate the results, we shall use S10, which employees the same step time and PH, resulting in a forecasting period of only one hour.
As shown in Figure 18, the first day is a cloudless day, with PV power exceeding the house consumption during the day period. The second day is also a sunny day, with a few clouds sometimes appearing. Battery power and BSC patterns are shown in Figure  19.  Notice that, in the last figure, the values of 1, 2, and 3 of the Actions signal denote discharging, maintaining, and charging the battery, respectively.
The situation of a sunny day is very different from the one shown previously. To illustrate the results, we shall use S10, which employees the same step time and PH, resulting in a forecasting period of only one hour.
As shown in Figure 18, the first day is a cloudless day, with PV power exceeding the house consumption during the day period. The second day is also a sunny day, with a few clouds sometimes appearing. Battery power and BSC patterns are shown in Figure  19. Notice that, in the last figure, the values of 1, 2, and 3 of the Actions signal denote discharging, maintaining, and charging the battery, respectively.
The situation of a sunny day is very different from the one shown previously. To illustrate the results, we shall use S10, which employees the same step time and PH, resulting in a forecasting period of only one hour.
As shown in Figure 18, the first day is a cloudless day, with PV power exceeding the house consumption during the day period. The second day is also a sunny day, with a few clouds sometimes appearing. Battery power and BSC patterns are shown in Figure 19. The proprietary control sells energy whenever it can, for instance, from around 07:00 to 09:00. As a consequence, it will have to buy energy from the grid later, at a much higher price. The energy exchanges from and to the grid are shown in the next figure.
In the case of this sunny day, the MBPC did not have to buy any energy from the grid (Figure 20a), while it could still export a significant quantity of energy (Figure 20b). A summary of the evolution of the signals described before can be found in the next figures, with the first one using the experimental data ( Figure 21) and the next one the MBPC (Figure 22). The proprietary control sells energy whenever it can, for instance, from around 07:00 to 09:00. As a consequence, it will have to buy energy from the grid later, at a much higher price. The energy exchanges from and to the grid are shown in the next figure.
In the case of this sunny day, the MBPC did not have to buy any energy from the grid (Figure 20a), while it could still export a significant quantity of energy (Figure 20b). A summary of the evolution of the signals described before can be found in the next figures, with the first one using the experimental data ( Figure 21) and the next one the MBPC (Figure 22). The proprietary control sells energy whenever it can, for instance, from around 07:00 to 09:00. As a consequence, it will have to buy energy from the grid later, at a much higher price. The energy exchanges from and to the grid are shown in the next figure.
In the case of this sunny day, the MBPC did not have to buy any energy from the grid (Figure 20a), while it could still export a significant quantity of energy (Figure 20b). A summary of the evolution of the signals described before can be found in the next figures, with the first one using the experimental data ( Figure 21) and the next one the MBPC ( Figure 22). The proprietary control sells energy whenever it can, for instance, from around 07:00 to 09:00. As a consequence, it will have to buy energy from the grid later, at a much higher price. The energy exchanges from and to the grid are shown in the next figure.
In the case of this sunny day, the MBPC did not have to buy any energy from the grid (Figure 20a), while it could still export a significant quantity of energy (Figure 20b). A summary of the evolution of the signals described before can be found in the next figures, with the first one using the experimental data ( Figure 21) and the next one the MBPC (Figure 22).   If we compare the action signals found in Figures 17 and 22, we can conclude that there are many more changes to the action signal on the cloudy than on the sunny day. This can be also be seen if we present a histogram of the last stable index in the branch and bound tree over the samples in the period considered. While in the sunny case, more than 300 actions out of the 468 are obtained in the very first level of the tree, unlike what happens on cloudy days. Cloudy days represent a much more complex problem, in terms of tree search.
Until now, it is more or less evident that the MBPC formulation achieved better results, both in terms of selling and buying (Figures 15 and 23) energy to/from the grid. It is now time to formulate these values quantitatively. As the experimental costs do not differ Power(kW) Power(kW) and Action   If we compare the action signals found in Figures 17 and 22, we can conclude that there are many more changes to the action signal on the cloudy than on the sunny day. This can be also be seen if we present a histogram of the last stable index in the branch and bound tree over the samples in the period considered. While in the sunny case, more than 300 actions out of the 468 are obtained in the very first level of the tree, unlike what happens on cloudy days. Cloudy days represent a much more complex problem, in terms of tree search.
Until now, it is more or less evident that the MBPC formulation achieved better results, both in terms of selling and buying (Figures 15 and 23) energy to/from the grid. It is now time to formulate these values quantitatively. As the experimental costs do not differ Power(kW) Power(kW) and Action If we compare the action signals found in Figures 17 and 22, we can conclude that there are many more changes to the action signal on the cloudy than on the sunny day. This can be also be seen if we present a histogram of the last stable index in the branch and bound tree over the samples in the period considered. While in the sunny case, more than 300 actions out of the 468 are obtained in the very first level of the tree, unlike what happens on cloudy days. Cloudy days represent a much more complex problem, in terms of tree search.
Until now, it is more or less evident that the MBPC formulation achieved better results, both in terms of selling and buying (Figures 15 and 23) energy to/from the grid. It is now time to formulate these values quantitatively. As the experimental costs do not differ with the considered prediction horizon, we can assume that, for a cloudy day, J s = 2.80 €, J b = 0.27 €, J n = J s − J b = 2.53 €.  MBPC was applied, considering times steps of 5, 10, and 15 min, and prediction horizons of 12, 24, and 36 steps ahead. There were no significant changes in the cost values, the optima values being achieved for 15 min and 36 steps ahead. For selling, MBPC obtained an average cost of EUR 1.80, corresponding to a reduction of 35% of the experimental cost. In terms of buying, MBPC obtained a cost of EUR 0.15, which is worse than the experimental value (EUR 0.27). In spite of this, a significant reduction in the net cost was obtained, as Jn for the MBPC was 1.65, corresponding to a reduction of 35% For a sunny day, we shall consider . This means that the proprietary system achieves a profit, not a cost. For all MBPC sunny scenarios, the selling cost is always null. MBPC obtained an average buying cost of EUR 0.81, corresponding to an improvement of 17% of the experimental cost. As the selling cost is null, the net cost is EUR −0.81, corresponding to an improvement of 224% over the proprietary system.
Considering both situations, the improvements are nearly independent of the time step employed, slightly better results being achieved for situations where the prediction horizon (in hours) is the largest, 9 h-situations S9 and S18 (described in Table 2). However, as can be seen in Table 2, the computation time is much higher than in the proprietary control, becoming, in practice, impractical when a higher prediction time is required.

Analysis 2-Control Horizon
In this section, we shall consider, as is often the case, that CH << PH. We shall address the two types of weather, considering two time steps (5 and 15 min), a constant PH of 36 steps, and control horizons varying from 2 to 4. The 12 new situations are shown in Table 3. MBPC was applied, considering times steps of 5, 10, and 15 min, and prediction horizons of 12, 24, and 36 steps ahead. There were no significant changes in the cost values, the optima values being achieved for 15 min and 36 steps ahead. For selling, MBPC obtained an average cost of EUR 1.80, corresponding to a reduction of 35% of the experimental cost. In terms of buying, MBPC obtained a cost of EUR 0.15, which is worse than the experimental value (EUR 0.27). In spite of this, a significant reduction in the net cost was obtained, as J n for the MBPC was 1.65, corresponding to a reduction of 35% For a sunny day, we shall consider J s = 0.44 €, J b = 0.69 €, J n = J s − J b = −0.25. This means that the proprietary system achieves a profit, not a cost. For all MBPC sunny scenarios, the selling cost is always null. MBPC obtained an average buying cost of EUR 0.81, corresponding to an improvement of 17% of the experimental cost. As the selling cost is null, the net cost is EUR −0.81, corresponding to an improvement of 224% over the proprietary system.
Considering both situations, the improvements are nearly independent of the time step employed, slightly better results being achieved for situations where the prediction horizon (in hours) is the largest, 9 h-situations S9 and S18 (described in Table 2). However, as can be seen in Table 2, the computation time is much higher than in the proprietary control, becoming, in practice, impractical when a higher prediction time is required.

Analysis 2-Control Horizon
In this section, we shall consider, as is often the case, that CH << PH. We shall address the two types of weather, considering two time steps (5 and 15 min), a constant PH of 36 steps, and control horizons varying from 2 to 4. The 12 new situations are shown in Table 3.  For a cloudy day, as happened for the full control horizons, the results obtained with the MBPC did not change significantly with varying time steps and control horizons. Comparing the performance obtained with small CHs to the full CH, we conclude that they are very similar, as the selling, buying, and net costs are the same with the resolution employed.
There is a slight improvement with increasing CHs, and the results seem to be independent of the time step employed. We can therefore conclude that, for a cloudy day, a time-step of 15 min, a PH of 36 steps, and a CH of 4 can be used, without a substantial degradation of performance.
In the same way as in the case of a full CH, the selling costs are zero with MBPC for all situations of the sunny day.
Comparing the performance obtained with small CHs to the full CH, similar results were also obtained for the same precision. As in the cloudy day, we can use a time step of 15 min, a PH of 36 steps, and a CH of 4, with minimum performance degradation.
The obtained reduction in the net cost were around 35% for the cloudy day, and the net profit obtained for the sunny day was over 220%. These represent excellent results, particularly because we are comparing the proposed MBPC against a much-commercialized system. As demonstrated previously, the PV-storage system already presented excellent values for self-sufficiency and self-consumption (see Figure 9). A fair comparison of these results with other published approaches is impossible because performance changes with the weather and there is, to our knowledge, no common comparison baseline available. We should stress that, in contrast with most of the works, we are using the same data to compare the performance of a real commercial PV-storage system with our MBPC proposal.
Nevertheless, we can point out some other performance values. In [14], improvements in profit of around 22-24% were obtained, in simulation, when a multi-objective predictive HEMS was compared with a naïve HEMS, in a fixed price scheme. The authors of [17] proposed a smart home energy management model designed to compute all optimal control scenarios through system analysis. Through the energy cost analysis, the cost gain on the demand side could reach approximately 8%. In [33], a 13.5% reduction in the energy cost is achieved with the centralized MPC compared to a rule-based energy management strategy. Despite achieving excellent results, the technique developed in this study has limitations, which will be dealt with in future work. Firstly, acquired values were used for the forecasting. In a real situation, this cannot occur. Secondly, battery degradation was not considered in the optimization, Thirdly, the performance of the proposed approach was only assessed in simulations, i.e., no control action was applied to the inverter.

Conclusions
One of the most important contribution of IoT technology to smart homes is in the efficient management of the energy within a single household, or throughout a community of households that employ decentralized renewable energy resources and energy storage. This way, the first contribution of this work is the development of a concise review of the most recent related works that integrate MBPC in residential HEMS, incorporating photovoltaic generation and storage. The interested reader should recall the last paragraph of Section 2.2, where the trade-off among different implementation decisions was described. The second, and most important, contribution is the proposal of an MBPC approach incorporating a Branch-and-Bound algorithm to improve the efficiency of the HEMS system, with small computational costs. Two sensitivity analysis were performed, the first assessing the impact of prediction horizon and step time on the economic costs/profits of an existing HEMS, and the second assessing the impact of the control horizon on computational time and cost/profit performance.
In the first part of the sensitivity analysis, 18 scenarios were explored, varying the day type (sunny and cloudy day), the time step between samples, and the prediction horizon, which has been made equal to the control horizon. Considering all 18 situations, the MBPC always improved the performance in comparison with the proprietary system. The improvements were nearly independent of the time step employed, slightly better results being achieved for situations where the prediction horizon (in hours) is the largest, 9 h-situations S9 and S18 (see Table 2).
To reduce the computational costs, in the second part of the sensitivity analysis, 12 scenarios were considered: varying the control horizon and keeping the prediction horizon fixed (36 steps-ahead). A substantial reduction in terms of the computational time was achieved, while maintaining nearly the same performance of the full control horizon approach. The obtained reduction in the net cost was 35% for the cloudy day, and the net profit obtained for the sunny day was over 220%. These represent excellent results, as our comparative basis is a commercially recognized brand system.
In this work, real values for all variables were employed, i.e., no forecasting of the home consumption and PV power generation were employed. Therefore, the current work is looking to incorporate these forecasts in the way described in past publications by the authors [39,49,50]. Another important issue to be tackled is the incorporation in the cost function of a contribution related to battery degradation. This can be dealt with in many ways, one of the most promising of which is a slight change of the BAB algorithm. A new version of the software of Plenticore Plus has been released, which allows external control of the inverter; therefore, we shall develop an upgraded real-time version of our algorithm.
Finally, as pointed out in the state-of-the-art review, there are several advantages of applying these intelligent algorithms, not only to a single house, but to a residential community. This is the topic of the latest research project of the group.