**1. Introduction**

The deregulation of the electric power industry has recently become a topic of attention for investors, regulators, and other participants who aim to achieve decarbonization in the energy sector and a more efficient use of energy [1]. In this context, smartgrids allow the enhancement of the efficiency of electricity utilization from the points of generation to the end users, and they enable the participation of prosumers on the demand side. Home nanogrids usually consist of renewable energy sources (RESs) and energy storage systems (ESSs) that can be used to store or release power when needed. Electric vehicles (EVs) using electricity produced by renewable sources appear as a promising solution for a sustainable transportation sector in the near future [2–6]. EVs use rechargeable battery packs to store the energy needed for propulsion. Smart buildings can be equipped with charging points where EV batteries can be recharged, for example, during nighttime [7]. On the other hand, concerns have been raised that are related to the peak power required to allow a proper recharge of EV batteries [4].

In this field, demand response (DR) will play an important role in the coordination of energy production and consumption by prosumers [8,9]. DR programs can be categorized as (i) incentive-based, where measures affect prosumers' behavior by providing incentives,

**Citation:** Simmini, F.; Caldognetto, T.; Bruschetta, M.; Mion, E.; Carli, R. Model Predictive Control for Efficient Management of Energy Resources in Smart Buildings. *Energies* **2021**, *14*, 5592. https://doi.org/10.3390/ en14185592


Academic Editor: Maria Carmela Di Piazza

Received: 29 July 2021 Accepted: 1 September 2021 Published: 7 September 2021

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

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

or (ii) price-based, where electricity price variations are used to induce the prosumers to correspondingly adapt their electricity usage [10–12]. Under this latter category, time of use (TOU) and real-time pricing (RTP) are the most commonly adopted approaches to retail pricing [9,13]. With TOU, electricity prices are changed in order to follow the shape of the demand (e.g., higher prices during peak-load periods), while with RTP, prices are modified to follow the trends of the electricity market.

In such a scenario, the flexible and efficient management of prosumers' energy resources is crucial in order to make DR a win–win solution for both the electrical system and the prosumers. The implementation of an efficient management system can be achieved through the development of advanced control strategies that aim to increase the demand flexibility and to minimize the economic expenditures of prosumers [14]. In this context, model predictive control (MPC) [15,16] represents one of the most promising control methodologies for achieving an efficient management of users' resources. MPC is an advanced control strategy whose aim is to minimize an objective function over a prediction horizon while always satisfying a set of system constraints; due to its versatility, it has been largely adopted in applications in power systems [17–23]. For example, in [24], an MPC method was developed for a microgrid equipped with photovoltaic (PV) sources and ESSs while taking both the economic expenditure given by the power exchange with the upstream grid and the battery's wear cost into account in the objective function. In that work, the results of the MPC were studied with respect to the difference between the purchase and sale prices, but the electricity price was kept constant. Varying electricity prices were considered in [25], in which an energy management system based on MPC was developed and experimentally tested. The experimental infrastructure was located at the FlexElec Laboratory in the University of Nottingham, and it comprised an ESS and PV panels. The target of the MPC was to minimize the electricity bill. In the study, particular attention was given to the economic performance of the predictive control as different parameters were varied, such as the ESS capacity and the PV size. In [26], the economic MPC developed was compared with a simple control method that was implemented in a rule-based manner. The performances of the developed MPC for different price scenarios were investigated in the paper, and it was underlined that, when compared with simple control solutions, the MPC presented advantages with time-varying prices and that such advantages increased as the energy price variability rose.

In this work, the predictive control is used to efficiently manage a home nanogrid equipped with a PV source, an ESS, and a connection to the upstream grid, with the specific task of recharging the battery of an EV while fulfilling all of the operational constraints. A typical scenario that assumes that the EV battery is recharged overnight to take advantage of the lower prices commonly applied by retailers is considered. By exploiting predictions of absorption and generation profiles, energy prices, times of departure and arrival of the EV, and daily EV battery energy consumption, the predictive control manages the available energy resources with a twofold aim:


The MPC is compared with a simple control method called the heuristic approach that, unlike the MPC, manages the system in a rule-based fashion without taking any future information into account. The two control strategies are compared by considering two different perspectives. The first one regards the economic performances of the approaches in two different price scenarios—a flat TOU rate and a steep TOU rate. In this context, the MPC proves to be a better solution than the heuristic approach because it achieves lower economic costs with greater economic savings for the steep TOU rate, which is characterized by a high purchase-price variability. In addition, rms current stresses are reduced thanks to the MPC approach. The second perspective regards the functionality of the control methods: the MPC is capable of fully recharging the EV battery during nighttime in scenarios in which the heuristic method is not. This merit is due to the

smart management allowed by the MPC approach, which is shown to be capable of fully exploiting the available resources while still satisfying all system constraints.

The organization of the paper is as follows. In Section 2, the system model of the nanogrid considered is reported. The heuristic approach is described in Section 3. Section 4 describes the proposed energy management system based on MPC. In Section 5, the MPC approach and the heuristic method are compared by considering the economic costs obtained in a seven-day simulation period, while Section 6 proposes a functional comparison between the two control approaches. The conclusions are reported in Section 7.

### **2. System Model**

The smart building under consideration is provided with a nanogrid that connects the energy sources and loads, as shown in Figure 1. The nanogrid is composed of:


**Figure 1.** Smart building: power values under consideration.

Both the ESS and the EVB are modeled as a dynamic discrete-time system with Δ*T* as sampling interval:

$$E\_{st}^{+} = E\_{st} - \Delta T \, P\_{st} \, \text{ \textit{\textquotedblleft}} \, \text{ \textit{\textquotedblleft}} \, E\_{ev}^{+} = E\_{ev} - \Delta T \, P\_{ev} \, \text{ \textit{\textquotedblleft}} \, \text{ \textit{\textquotedblleft}} \, \text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblright}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblright}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblright}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblleft}} \,\text{ \textit{\textquotedblright}} \,\text{ \textit{\textqull}} \,\text{ \textit{\textqull}} \,\text{ \textit{\textqull}} \,\text{ \textit{\textqull}} \,\text{ \textit$$

where *Est* and *Eev* are the stored energy in the ESS and EVB, respectively, with superscript <sup>+</sup> referring to the value of the variable at the following time.

The model of the system with *Pst* and *Pev* as inputs can be summarized in the following discrete-time equation:

$$
\begin{bmatrix} E\_{\rm st}^{+} \\ E\_{\rm t\upsilon}^{+} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} E\_{\rm st} \\ E\_{\rm t\upsilon} \end{bmatrix} + \begin{bmatrix} -\Delta T & 0 \\ 0 & -\Delta T \end{bmatrix} \begin{bmatrix} P\_{\rm st} \\ P\_{\rm t\upsilon} \end{bmatrix}. \tag{2}
$$

According to Figure 1, the power balance equation of the nanogrid is given in the following:

$$P\_l = P\_{pv} + P\_{st} + P\_{ev} + P\_{\mathcal{S}}\,. \tag{3}$$

### **3. Heuristic Approach**

In this paper, the proposed MPC strategy is compared with a rule-based technique, which is called the heuristic approach hereinafter.

When the EV is connected to the nanogrid (i.e., during nighttime), the heuristic method devotes all the available resources to the charging process of the EVB; to this purpose, at each time step, given the current value of the battery's state of charge *Eev*, by exploiting (1), the signal *P*¯ *ev* is computed as:

$$
\vec{P}\_{cv} = \frac{E\_{cv} - E\_{cv,max}}{\Delta T} \,\tag{4}
$$

When the EV is not connected to the nanogrid (i.e., during daytime), signal *P*¯ *ev* becomes:

$$
\mathcal{P}\_{\text{cv}} = 0 \text{ W} \,. \tag{5}
$$

The heuristic method manages the ESS to achieve *Pg* = 0, if possible; at each time step, it compares the values of *Ppv* and *Pl* <sup>−</sup> *<sup>P</sup>*¯ *ev*:

	- **–** If *Pg* is lower than or equal to *Pg*,*max*, the EV charging power is given by:

$$P\_{\rm ev} = P\_{\rm ev};\tag{6}$$

**–** If *Pg* exceeds *Pg*,*max*, the grid power is set to satisfy the upper bound limit:

$$P\_{\mathcal{S}} = P\_{\mathcal{S}, \text{max}}.\tag{7}$$

and the resulting EV charging power is yielded by (3):

$$P\_{\rm c\overline{v}} = P\_l - P\_{p\overline{v}} - P\_{\rm st} - P\_{\mathcal{S}}\;\prime \tag{8}$$

• If *Ppv* <sup>&</sup>gt; *Pl* <sup>−</sup> *<sup>P</sup>*¯ *ev*, the excess power is stored in the ESS; in case the ESS is full or does not have sufficient power capacity, the unused power is diverted into the grid. As far as the EVB is concerned, because, in this case, the following inequality holds:

$$P\_{\mathcal{S}} \le 0 < P\_{\mathcal{S}, \max \mathcal{A}} \tag{9}$$

the actual power absorbed by the battery is given by:

$$P\_{cv} = P\_{cv} \,. \tag{10}$$

It is worth noting that, at each time step, the computed power *P*¯ *ev* is a fictitious signal; the actual EVB charging power *Pev* is equal to *P*¯ *ev* if *Pg* ≤ *Pg*,*max*.

The steps of the heuristic approach are shown in Figure 2.

**Figure 2.** Heuristic approach: flowchart.

## **4. Model Predictive Control**

Model predictive control is an advanced model-based control strategy whose aim is to optimize the evolution of a system over a future time span. At each sampling time, the predictive control computes the control signal by minimizing a cost function over a prediction horizon while taking system constraints into account. Only the first input of the signal is applied; then, the model state is updated and the optimization operation is iterated by adopting a receding horizon strategy.

In the proposed energy management system formulation, the MPC exploits future information about the expected power absorption and generation profiles, energy prices, times of departure and arrival of the EV, and daily EVB energy consumption with the aim of:


In this paper, a particular case is considered in which future information about production and absorption profiles, departure and arrival times of the EV, and daily EVB

energy consumption is assumed to be known, as the target is to highlight the advantages that can potentially be obtained by exploiting predictive approaches. Studying how prediction errors may degrade the performance of the MPC procedure will be the target of future work.

### *4.1. Cost Function*

The MPC computes the control inputs that minimize the cost function *J* over a prediction horizon *Np*:

$$\min\_{\{P\_{st}(k), P\_{cv}(k)\}} J = J\_{\epsilon} - J\_{f, \epsilon} \tag{11}$$

with

$$J\_{\mathcal{E}} = \Delta T \sum\_{k=1}^{N\_p} \left( c\_{\mathcal{P}}(k) \text{max}(P\_{\mathcal{S}}(k), 0) + c\_{\mathcal{S}}(k) \text{min}(P\_{\mathcal{S}}(k), 0) + c\_{ESS}|P\_{\mathcal{S}t}(k)| \right), \tag{12}$$

and

$$J\_f = c\_f E\_{st}(N\_p). \tag{13}$$

*Je* is the economic cost over the prediction horizon and is given by the sum of the following three terms:


The term *Jf* represents an economic value that is proportional to the final state of charge of the ESS in the prediction horizon via the positive coefficient *c <sup>f</sup>* , which is measured in EUR/kWh. High values of *c <sup>f</sup>* may lead to a fully charged ESS at the end of the prediction horizon, whilst low values lead to an empty ESS. The best setting of this coefficient depends on the price scenario under consideration and aims to mitigate the effect of a limited prediction horizon on the economic cost.

From (1), the following equation holds:

$$E\_{\rm st}(N\_p) = E\_{\rm st}(0) - \Delta T \sum\_{k=1}^{N\_p} P\_{\rm st}(k) \,. \tag{14}$$

Then, the cost function *J* can be written as follows:

$$J = \Delta T \sum\_{k=1}^{N\_p} \left( c\_{\mathcal{P}}(k) \max(P\_{\mathcal{S}}(k), 0) + c\_{\mathcal{S}}(k) \min(P\_{\mathcal{S}}(k), 0) + c\_{ESS}|P\_{\mathcal{S}t}(k)| + c\_f P\_{\mathcal{S}t}(k) \right). \tag{15}$$

### *4.2. System Constraints*

The MPC minimizes the cost function in (15) in the prediction horizon under the following constraints for the ESS:

$$\begin{cases} E\_{st,min} \le E\_{st} \le E\_{st,max} \\ P\_{st,min} \le P\_{st} \le P\_{st,max} \end{cases} \tag{16}$$

Considering the EVB constraints, when the EV is connected to the nanogrid (i.e., during nighttime), the following constraints hold:

⎧ ⎪⎨ ⎪⎩ *Eev*,*min* ≤ *Eev* ≤ *Eev*,*max Eev*(*Td*,*i*) = *Eev*,*max Pev* ≤ 0 , (17)

where *Td*,*<sup>i</sup>* refers to the departure time of the EV at the end of the *i*-th nighttime period; in this way, the MPC procedure ensures, if possible, a full EVB at the departure time. Otherwise, when the EV is not connected to the nanogrid (i.e., during daytime), the following equality constraint holds:

$$P\_{\rm ev} = 0.\tag{18}$$

As regards the grid power, the MPC optimizes the system under the following inequality constraint:

$$P\_{\mathcal{S}} \le P\_{\mathcal{S},\max} \,. \tag{19}$$

### *4.3. Estimating the Economic Cost of ESS Wear*

In the literature dealing with the economic optimization tasks for ESSs, a term in the cost function is usually added with the aim of preserving the life expectancy of the storage. In this paper, a common approach is adopted that consists of including a term that is proportional to the absolute value of the ESS's exchanged output power in the cost function [18]. The coefficient *cESS* in (15) is defined as the ratio between the ESS price and the total energy throughput bearable by the ESS in its whole usable life:

$$x\_{ESS} = \frac{C\_{ESS}}{2N\_{cy}E\_{st,N}},\tag{20}$$

where *CESS* is the cost of the ESS, *Ncy* is its expected cycle lifetime, and *Est*,*<sup>N</sup>* is its capacity.

It is worth noting that since the aim of the MPC is to fully charge the EVB during nighttime with the constraint *Pev* ≤ 0, no EVB degradation cost is included in the cost function (15); the inclusion of a battery degradation cost would not modify the optimization results.

### **5. Economic Comparison**

In this section, the economic performances of the MPC and the heuristic method are compared by considering different price scenarios. The first price scenario considers a TOU tariff with low purchase-price variations, and it is based on rates that are currently available in Italy. The second tariff considers typical Australian TOU rates with a high purchase-price variation between nighttime and daytime.

The nanogrid under consideration is provided with an ESS with a nominal capacity of 13.5 kWh and maximum output power of 4 kW, which corresponds to a commercial size for the considered application [27]; it is assumed that the ESS can be used in the range [*Est*,*min*, *Est*,*max*], where *Est*,*min* and *Est*,*max* are equal to 2 and 13.5 kWh, respectively. The ESS is assumed to have an expected lifetime of 5000 cycles and a cost of 7030 EUR, which means that *cESS* = 0.0521 EUR/kWh.

The EV is provided with a battery with a nominal capacity of 42 kWh, which is an average and representative value considering the current storage capacities of EVs of small/medium size [28]. The EVB can be used in the range [*Eev*,*min*, *Eev*,*max*], where *Eev*,*min* and *Eev*,*max* are equal to 6 and 42 kWh, respectively. A typical scenario is considered in which the driver leaves home in the morning and returns home in the afternoon or in the evening. The times of departure and arrival of the EV and the corresponding battery energy consumption during the week are reported in Table 1. An average consumption of 28.49 kWh per 100 statute miles is assumed, which is typical for the size of the considered EV, considering a driver traveling, on average, about 33.40 statute miles per day [29]. It is assumed that the EV connects to the nanogrid at the time of arrival.


**Table 1.** The departure and arrival times and EVB energy consumption considered.

In the simulations, the model sample time is 60 s, while the control sample time is set to one hour for both the MPC and the heuristic method. The prediction horizon is set to 24 h in the predictive controller; this choice represents a proper trade-off between the reliability of predictions and energy cost minimization; shorter prediction horizons would bring an increase in the economic costs.

The two control procedures are compared in a seven-day simulation period, where the load and PV data refer to an installation of a rated load power of 3 kW and a rated PV generation unit of 4 kW; the average daily energy absorbed by the loads is about 16.15 kWh/day, while the average daily PV energy generated is about 13.26 kWh/day.

### *5.1. Scenario 1: MPC—Flat Time-of-Use Rate*

A TOU retail tariff typically applied in the Italian market is adopted in this scenario [30]; it is characterized by a slightly varying purchase price based on three time intervals: (i) high consumption (midday hours), (ii) low consumption (nighttime), and (iii) weekends. Prices in the second and third intervals usually coincide in the Italian market.

As regards the selling price, in Italy, a state-run net metering scheme for power injections of small generators is employed; excess PV energy is sold at market price, and then, at the end of the year, the prosumer receives a payment based on the injected and absorbed energy [31].

In this price scenario, the coefficient *c <sup>f</sup>* is set to 0.17 EUR/kWh. It was verified that both lower and higher values can bring an increase in the economic cost; with lower values, the controller cannot exploit all of the available PV power to charge the ESS, while with higher values, the discharge of the ESS when demand exceeds production cannot be guaranteed, even in the case of the availability of energy in the ESS.

Figure 3 shows the energy prices and the predictive control simulation results. The cost of energy (Figure 3a) is 0.2642 EUR/kWh from 8 a.m. to 8 p.m. and 0.2424 EUR/kWh from 8 p.m. to 8 a.m. on working days, while on the weekend, it is a constant signal that is equal to 0.2424 EUR/kWh. The sale price changes on a daily basis, with small variations. In the simulations, it was assumed that the sale price for the upcoming day is known at 4 p.m.; in case of an unknown sale price at a specific time in the prediction horizon, the controller is fed with an average value based on the three previous days.

(**a**) Purchase and sale prices

(**b**) Power

(**c**) State of charge of the ESS

(**d**) State of charge of the EVB

**Figure 3.** MPC results with the flat TOU rate in a simulation of one week.

Power profiles are given in Figure 3b, while the states of charge of the ESS and the EVB are reported in Figure 3c,d, respectively (in Figure 3d, the time interval in which the EV is not connected to the nanogrid is shaded). It can be observed that that the ESS charges if the production exceeds the load during the daytime, while during the nighttime, power is driven from the ESS to the EVB, if possible (e.g., during the night between Saturday and Sunday); if the ESS cannot provide enough energy to charge the EVB, the predictive control purchases the required energy from the grid during the low-price periods. Notably, the MPC proves to be able to fully charge the EVB by smartly managing available energy resources with minimal economic expenditures.

### *5.2. Scenario 2: MPC—Steep Time-of-Use Rate*

A tariff currently applied in the Australian electricity market is considered in this scenario [32]. It is characterized by a high variability in purchase price based on the following time intervals: (i) peak (midday hours), (ii) shoulders (morning, late evening, and weekend), and (iii) off-peak (nighttime). Furthermore, Australian retailers apply a daily charge between 0.90 and 1.20 AUD/day; in this case, a daily supply charge of 1.10 AUD/day is considered. As regards the selling price, in Australia, a flat rate that varies between 0.09 and 0.12 AUD/kWh is adopted; here, a sale price *cs* equal to 0.12 AUD/kWh is applied. In the tests performed, an exchange rate of 0.6 EUR/AUD is considered.

In this price scenario, the coefficient *c <sup>f</sup>* is set to 0.15 EUR/kWh. As described above, both lower and higher values can lead to an increase in the economic cost.

Figure 4 reports the simulation results for the MPC approach. On working days, the purchase price is 0.2376 EUR/kWh from 3 p.m. to 9 p.m. (peak), 0.1295 EUR/kWh from 7 a.m. to 3 p.m. and from 9 p.m. to 10 p.m. (shoulder), and 0.1086 EUR/kWh from 10 p.m. to 7 a.m. (off-peak). On the weekends, it is 0.1295 EUR/kWh from 7 a.m. to 10 p.m. (shoulder) and 0.1086 EUR/kWh from 10 p.m. to 7 a.m. (off-peak). The sale price is a constant signal that is equal to 0.072 EUR/kWh.

Differently from the previous price scenario, on Wednesday, the ESS charges during the off-peak time, thus exploiting the grid with the aim of satisfying the daytime demand during the peak price period, since the ESS is empty at the beginning of the considered period and the controller predicts a lack of generation in the prediction horizon; this is due to the daily purchase price difference, which is higher than 2*cESS* [26]. It is worth noting that the ESS is used only to satisfy the demand during the peak period of the working days, while on the shoulders and off-peak times, the grid is exploited to satisfy the load and to charge the EVB. Unlike in the previous scenario, there is no power transfer from the ESS to the EVB. This happens because, at the shoulder and off-peak times, the difference between the purchase and selling prices is lower than 2*cESS*; the use of the ESS would increase the economic costs with respect to the solution of exploiting the grid to charge the EVB due to the cost of wear of the storage. Similarly to scenario 1, the MPC buys energy to charge the EVB during the lowest price period (from 10 p.m. to 7 a.m.).

(**a**) Purchase and sale prices

(**b**) Power

(**c**) State of charge of the ESS

(**d**) State of charge of the EVB

**Figure 4.** MPC results with the steep TOU rate in a simulation of one week.

### *5.3. Simulation with the Heuristic Approach*

Figure 5 reports the simulation results for the heuristic method. The same results are achieved for the two price scenarios considered, since the implementation of the algorithm of the heuristic approach does not depend on energy prices. During the daytime, when production exceeds absorption, excess PV power is diverted into the ESS or, if the storage is full, into the grid. Instead, when the PV power is lower than the load, the deficit is satisfied by the ESS or, if empty, by the grid. At the arrival time, the heuristic approach uses all of the available resources to charge the EVB, and then exploits the power provided by the ESS with an upper bound of 4 kW and that of the grid with an upper bound of 3 kW. As seen with the MPC, during the nighttime, the heuristic method is capable of fully recharging the EVB before the next departure time.

(**b**) State of charge of the ESS

(**c**) State of charge of the EVB

**Figure 5.** Results of the heuristic approach in a simulation of one week.

### *5.4. Economic Costs*

In this subsection, the performances of the predictive control and the heuristic method are evaluated by comparing the economic costs achieved in the simulations reported above.

The economic costs for the MPC and the heuristic approach in the considered price scenarios are reported in Table 2; the overall economic cost consists of the three terms defined in Section 4.1:


as well as the charge, which comes from a fixed daily value of 0.66 EUR/day in Scenario 2, while in Scenario 1, there is no charge.



As far as the overall economic costs are concerned, the economic savings of the MPC compared to the heuristic strategy are 2.05% in Scenario 1 and 25.40% in Scenario 2, rising up to 31.32% if the charge is not considered. The performance of the MPC increases with the increase in the daily price variability. In Scenario 1, which is characterized by a low daily variability of the purchase price, low savings are achieved, while in Scenario 2, much greater savings are achieved due to the high variation in the purchase price.

The MPC proves to be a better solution than the heuristic technique because it obtains lower economic costs by smartly managing available energy resources. Notably, such smart control actions are not possible with techniques that act in an instant manner, such as the heuristic approach considered here. It is worth remarking that the economic advantages obtained increase as the daily price variability rises [26].

Statistical results from the different cases are shown in Figure 6; the MPC substantially exhibits the advantage of providing lower *I*<sup>2</sup> *<sup>g</sup>* (which is related to network losses) and lower *I*<sup>2</sup> *st* and *I*<sup>2</sup> *ev* (which are associated with battery degradation and converter losses) with respect to the heuristic method.

**Figure 6.** Statistical results in the considered interval of one week: *Ig* = *Pg*/*Vg*,*N*, *Ist* = *Pst*/*Vst*,*N*, *Iev* = *Pev*/*Vev*,*N*, *Vg*,*<sup>N</sup>* = 230 V, *Vst*,*<sup>N</sup>* = 50 V, *Vev*,*<sup>N</sup>* = 400 V. *Vg*,*N*, *Vst*,*N*, and *Vev*,*<sup>N</sup>* refer to the nominal voltage of the grid, the ESS, and the EVB, respectively.

### **6. Functional Comparison**

In this section, the MPC approach and the heuristic method are compared from a functional perspective. As in the example in the previous section, a seven-day simulation period is considered. The ESS and the EVB have the same characteristics as those introduced in Section 5. The planned schedule of departures and arrivals of the EV is provided in Table 3. Unlike in the example in the previous section, a much greater discharge of the EV battery in three days of the week (i.e., Friday, Saturday and Sunday) is considered. During the daytime, the EV is assumed to exploit all available energy stored in the battery (36 kWh).

**Table 3.** Functional comparison: planned departure and arrival times and EVB energy consumption.


In the tests performed here, the control sample time is set to one hour for both control approaches; the MPC is implemented with a one-day prediction horizon. As far as the grid power is concerned, *Pg*,*max* is set to 3 kW.

In the simulations, the average daily energy absorbed by the loads is about 16.15 kWh/day, while the average daily energy generated by the PV panels is about 16.76 kWh/day.

Figure 7 shows the simulation results for the MPC approach in the flat TOU rate scenario. It is worth noting that, on Friday, Saturday, and Sunday, MPC successfully manages the energy resources (i) to fully charge the EVB during the nighttime and (ii) to respect the upper bound of 3 kW for the maximum power absorbed from the grid. On the one hand, during the daytime on Friday and Sunday, since there is lack of production, the predictive controller uses the grid to charge the ESS until reaching the state of charge that ensures a full EVB at the departure time of the following day. On the other hand, on Saturday, the MPC smartly manages available resources by exploiting the grid to satisfy the demand in the afternoon with the aim of leaving enough energy for nighttime charging in the ESS.

Figure 8 shows the simulation results for the heuristic approach. It is worth noting that, unlike the MPC, the heuristic approach is not able to ensure a full EVB before the departure times on Saturday, Sunday, and Monday. In detail, at the arrival time on Friday and Sunday, the ESS is empty, so it cannot provide energy to the EVB during the next night. On Saturday, the heuristic approach badly manages the ESS, since it exploits the stored energy in the afternoon before the arrival time of the EV; the remaining energy at the arrival time is not enough to guarantee a full EVB on Sunday morning. As a consequence of poor resource management, there is a decrease in the mileage with respect to what is planned (Table 3) on Saturday and Sunday because the driver has to satisfy the lower bound constraint of the EVB (6 kWh). Indeed, differently from the MPC case, the actual EVB energy consumption obtained with the heuristic method decreases by about 26% on Saturday and 9% on Sunday. It is worth remarking that, in this scenario, an economic comparison between the MPC and the heuristic method would be meaningless, as the mileage of the EV is different in the two cases.

In the above example, the heuristic approach shows the functional disadvantage of not being able to fully charge the EVB during the nighttime; on the other hand, this is possible through the use of predictive control techniques that manage the available resources by exploiting future information. The previous example highlights the potential for MPC in future contexts, since, by smartly managing available energy resources, it can guarantee the desired functionalities, which cannot be always ensured by simple heuristic techniques. Moreover, while satisfying the additional requirements of EV charging, the MPC is shown to be capable of keeping the peak power absorption from the grid constrained within nominal limits, which is an aspect of relevant concern considering the expected widespread use of electric vehicles.

(**a**) Purchase and sale prices

(**b**) Power

(**c**) State of charge of the ESS

(**d**) State of charge of the EVB

**Figure 7.** Functional comparison: results of the MPC with the flat TOU rate in a simulation of one week.

### **7. Conclusions**

This paper shows the application of model predictive control for the efficient management of prosumers' energy resources in the presence of local energy storage capabilities and an electric vehicle (EV). The aim of the predictive control developed here is the minimization of the economic cost with the constraint of ensuring a full EV battery at departure times. The proposed predictive approach is compared with a heuristic method that manages the available resources in an instantaneous rule-based manner. The simulation results show that, on the one hand, the MPC provides lower costs in scenarios in which both strategies are able to fully charge the EV battery during the night. On the other hand, it can guarantee a full recharge in scenarios in which the heuristic method is not capable of doing so. In summary, the simple scenario considered here allowed us to highlight the remarkable advantages of using predictive approaches in such an application, even while considering different energy pricing schemes. It is shown that the MPC algorithm, through optimal management of the available resources, allows one to (i) to meet functional

objectives, such as the full recharge of the EV battery, (ii) allow the economic management of local resources, (iii) reduce rms current values at the interface with the mains and the local energy storage system, and (iv) keep the power exchanged with the mains within nominal ranges.

Future developments of the presented research may include the study of the effect of prediction errors on the performance of the MPC procedure and a sensitivity analysis of the MPC's performance as different parameters vary (e.g., length of the prediction horizon, energy storage capacities, PV system size).

**Author Contributions:** Conceptualization, F.S., T.C., M.B., E.M. and R.C.; methodology, F.S. and T.C.; software, F.S.; validation, F.S.; investigation, F.S. and T.C.; writing—original draft preparation, F.S.; writing—review and editing, F.S., T.C., M.B. and E.M.; supervision, R.C. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the Interdepartmental Centre Giorgio Levi Cases, University of Padova, NEBULE project.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** The data presented in this study are available on request from the corresponding author.

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

### **References**

