MILP Optimized Management of Domestic PV-Battery Using Two Days-Ahead Forecasts

This paper proposes an Energy Management System (EMS) for domestic PV-battery applications with the aim of reducing the absolute net energy exchange with the utility grid by utilizing the two days-ahead energy forecasts in the optimization process. A Mixed-Integer Linear Programming (MILP) exploits two days-ahead energy demand and PV generation forecasts to schedule the day-ahead battery energy exchange with both the utility grid and the PV generator. The proposed scheme is tested using the real data of the Active Office Building (AOB) located in Swansea University, UK. Performance comparisons with state-of-the-art and the commercial EMS currently running at the AOB reveal that the proposed EMS increases the self-consumption of PV energy and at the same time reduces the total energy cost. The absolute net energy exchange with the grid and the total operating costs are reduced by 121% and 54% compared to the state-of-the-art and 194% and 8% when compared to the commercial EMS over a six-month period. Furthermore, the results show that the proposed method can reduce the energy bill by up to 46% for the same period compared to the state-of-the-art. The paper also investigates the effect of using different objective functions on the performance of the EMS and shows that the proposed EMS operate more efficiently when it is compared with another cost function that directly promotes reducing the absolute net energy exchange.

ABSTRACT This paper proposes an Energy Management System (EMS) for domestic PV-battery applications with the aim of reducing the absolute net energy exchange with the utility grid by utilizing the two days-ahead energy forecasts in the optimization process. A Mixed-Integer Linear Programming (MILP) exploits two days-ahead energy demand and PV generation forecasts to schedule the day-ahead battery energy exchange with both the utility grid and the PV generator. The proposed scheme is tested using the real data of the Active Office Building (AOB) located in Swansea University, UK. Performance comparisons with state-of-the-art and the commercial EMS currently running at the AOB reveal that the proposed EMS increases the self-consumption of PV energy and at the same time reduces the total energy cost. The absolute net energy exchange with the grid and the total operating costs are reduced by 121% and 54% compared to the state-of-the-art and 194% and 8% when compared to the commercial EMS over a six-month period. Furthermore, the results show that the proposed method can reduce the energy bill by up to 46% for the same period compared to the state-of-the-art. The paper also investigates the effect of using different objective functions on the performance of the EMS and shows that the proposed EMS operate more efficiently when it is compared with another cost function that directly promotes reducing the absolute net energy exchange.
INDEX TERMS Battery storage, energy management system, energy tariffs, forecast, mixed-integer linear programming, PV.
The associate editor coordinating the review of this manuscript and approving it for publication was Behnam Mohammadi-Ivatloo .

SOC(t)
Battery state of charge (%). E Day-f Day-2 peak time energy forecast (kWh).

SOC max
Maximum limit of the state of charge (%).

SOC min
Minimum limit of the state of charge (%).

E(t)
Energy stored in the battery at time t (kWh).
Energy stored in the battery at time t − 1 (kWh). P G (t) Power exchange with the utility grid (kW). P G max-export Maximum limit exported power to the utility grid (kW). VOLUME  Exported energy to the utility grid (kWh).

I. INTRODUCTION
Decarbonization and limited resources of fossil fuels (used in conventional power generation plants) have increased the demand for integrating Renewable Energy Sources (RESs) such as PV systems, especially for domestic applications [1]. Historically, Feed-in-Tariff (FIT) initiatives were introduced in several regions for small-scale-based RESs connected to the utility grid. However, high penetration of RESs, especially at the distribution level (where conventionally only consumption occurred), has created numerous challenges for the network operators [2]. As a result, in several countries like the UK, incentives are already reduced, encouraging a self-consumption approach. For example, the generation tariff (part of the FIT) in the UK has reduced from more than 54 p/kWh in 2010 to 3.79 p/kWh in 2019 [3], when the FIT has been replaced by the Smart Export Guarantee (SEG) scheme. The SEG requires some electricity suppliers to pay small-scale generators between 2 p/kWh and 5.6 p/kWh for their low-carbon electricity which they export to the grid [4]. It is noted that the SEG rates in the UK are currently less than the electricity purchasing prices. In addition, many countries such as the UK and Germany have already enforced some other measures to limit the surplus PV energy injection to the utility grid to encourage the self-consumption approach [5].
The main characteristic of this new trend is the minimization of the net energy exchange between the prosumer (producer + consumer) and the grid [6]. An effective self-consumption approach benefits from some sort of Battery Storage Systems (BSSs) and an intelligent Energy Management System (EMS). Based on previous literature, decision-making at the energy management level can be achieved either heuristically, such as rule-based-EMS [7], [8] or non-heuristically using optimization methods [1]. In terms of implementation, EMSs can be either online [7] or offline [1]. Also, different objectives can be defined as the main priority for EMSs, e.g., several works focused on reducing the energy bill using the BSS scheduling [9], while some other works proposed EMSs that schedule domestic appliances based on their priority and time of the day [8], [10], [11]. Authors in [12] proposed EMS based on a user priority list that can achieve savings of up to 87%. Similarly, authors in [13], [14] proposed an optimal load scheduling to reduce energy costs and peak loads. However, controlling the local loads approach is not preferable for some clients as it may affect their comfort.
There are various control algorithms in the literature proposed for EMSs. For example, the authors in [15] proposed a rule-based controller for real-time price-based EMS. Their work considered emergency load curtailment and vehicleto-home support during interruption events. Authors in [16] and [17] proposed a rule-based EMS to maintain the power balance in the Micro-grid (MG) and reduce the bill. Similarly, authors in [7], [18], [19] proposed a Fuzzy Logic (FL)-based-EMS to minimize the energy cost. Although FL controllers and rule-based approaches can successfully deal with the MG components' nonlinearities and avoid complex mathematical modeling, they rely on the designer's justified rules, which may not be comprehensive in all aspects.
Authors in [20] proposed domestic EMS based on genetic harmony search algorithm to reduce the operating costs. However, their proposed system did not include the BSS. In [21] the proposed domestic EMS was applied to reduce the operating costs, while their system limited the BSS to store 30% of RES energy during the daytime. This limit deteriorates the PV local utilization and increases the imported energy from the grid.
In previous works, little consideration is given to the impact of the battery State of Health (SOH) during its operational lifetime as an effective factor in the EMSs. To overcome this shortage, authors in [22] and [23] limited the battery State of Charge (SOC) to 50% at the cost of increased capital costs and undermining PV self-consumption. Moreover, this simple approach while beneficial for battery health, it underutilizes the battery capacity. An alternative solution is to include battery degradation cost as an indication of the SOH of the battery [1], [24], [25].
Authors in [26] proposed an EMS for islanded MGs. The main target of their proposed method was to reduce the BSS degradation and improve the utilization of RESs. Authors in [27] proposed a centralized MG controller to reduce the conversion losses and the energy cost in the residential distribution system. In [28], Linear Programming (LP) was used for BSS scheduling, where the method is reported to achieve a high reduction in energy cost and greenhouse gases emission compared to the case where loads were only supplied by the grid. Authors in [29] considered the operational and maintenance cost of the solar units and the BSS in the objective function. Authors in [26]- [29] considered one day-ahead energy forecast in the optimization to achieve optimal day-ahead battery operation. However, their methods do not utilize the knowledge of the following day (day-2) energy forecasts which may cause unnecessary energy exchange with the grid. For example, the lack of knowledge of day-2 will result in exporting the available RES surplus energy to the utility grid rather than storing that energy in the BSS. Therefore, if on the next day (i.e. day-2), the PV generation is less than the load, the exchange energy with the utility grid and the energy bill will unnecessarily increase.
Several studies have been conducted using computational intelligence methods to solve the EMS optimization problems, such as Ant Colony optimization [30], Grey Wolf optimization [10], and Particle Swarm Optimization (PSO) [31].
While many studies focused on proposing different forecasting algorithms [5], there are significantly fewer published works identifying how best to utilize and integrate the forecasted data into an EMS. This study does not utilize a specific forecast method but approximates the forecasted data by imposing normally distributed random numbers on the historical data [32]. The main objective of this paper is to minimize the energy bill while the net exchanged energy with the utility grid is reduced through exploiting the two days-ahead energy forecasts in the adaptive optimization process. This reduces the distribution and transmission losses and grid voltage rise by enhancing the self-consumption of PV energy. The Active Office Building (AOB) located in Swansea University, is used as a case study to demonstrate the developed EMS. The proposed model equations are solved using the Mixed-Integer Linear Programming (MILP) optimization method and Gurobi optimizer in MATLAB.
The key contributions of this work can be summarised as follows: a) Making better use of the BSS by including the two days-ahead forecasts in the EMS. b) Proposing an EMS using the MILP optimization method such that: i. it reduces the absolute net energy exchange with the grid, which in turn reduces the burdens on the utility grid and the losses; ii. it reduces the overall electricity bill; iii. it reduces the overall operating costs of the system by considering the capital and the degradation costs of the BSS in the EMS. The rest of the paper is organized as follows. Section II describes the system configuration, section III introduces the proposed EMS. Section IV presents the problem formulation, and section V presents the simulation results and discussion. Finally, the conclusions of this work are presented in section VI.  [33]. Moreover, the maximum SOC (SOC max ) and the minimum SOC (SOC min ) limits are set to 98% and 20%, respectively [7].

III. PROPOSED ENERGY MANAGEMENT SYSTEM
The proposed EMS aims to minimize the absolute net energy exchanged with the utility grid to enhance PV self-consumption while reducing the overall operational costs.
The proposed EMS method follows the procedures shown in Fig. 2, and detailed in the below steps: • first, the EMS asks for the initial SOC of the BSS. • then the two days-ahead forecasted data are requested: day-1 PV generation (P PV −1 ), day-2 PV generation (P PV −2 ), day-1 load demand (P L−1 ), and day-2 load demand (P L−2 ).
• then the EMS calculates the peak time energy forecast (E Day-f ) from day-2 forecasted data as shown in (1): • the MILP optimization is then performed for one dayahead (i.e., day-1) to obtain the BSS scheduling. • finally, the EMS gets the decision variables, i.e., the utility grid power (P G ) and battery power (P B ), and send the signal to the BSS.

IV. PROBLEM FORMULATION
The objective function focuses on minimizing the absolute net energy exchange with the utility grid while considering the energy cost. The problem is formulated using MILP optimization. The algorithm aims to minimize the cost function (C F ), which includes the price of energy imported from the utility grid (C buy ), price of energy exported to the utility grid (C sell ) and the BSS degradation cost (C BSS ).
It is worth noting that the C F considers the C buy and C sell as absolute values to reduce the net exchanged energy with the utility grid (i.e. reducing the total energy transactions). In addition, the C BSS is included in the cost function to consider the battery lifetime. The bill cost (C bill ) is calculated by subtracting the C sell from C buy (note that C sell is a negative value): The surplus PV energy is exported to the utility grid after supplying the load and charging the BSS. The selling and purchasing energy costs are calculated as [1]: where the t 0 is the start time of the day, 12 AM, T is 24 hours, T (hr) is the sampling period of ten minutes, f buy (t) is the purchasing tariff from the utility grid (£/kWh), f sell (t) is the feed-in tariff (£/kWh) to the utility grid.
Equation (6) represents the power balance equation of the system: A

. BATTERY MODEL
The BSS model is established as follows. The degradation cost of each charging/discharging cycle is represented as in (7) [1]: where the CC B represents the capital cost of the battery (£) (not including the power converters), N cycle is the number of life cycles of the battery, η conv is the battery DC/DC converter efficiency (%), P B disch is the battery discharge power (kW), P B charg is the battery charge power (kW), η d and η c are the battery discharging and charging efficiencies (%). Note that P B charg is a negative value and P B disch is a positive value. The stored energy in the BSS and the SOC of the battery can be estimated as [1]: where E(t) and E(t − 1) are the energy stored in the battery at time t and t − 1, respectively, and B capacity is the battery capacity.
The BSS settings of the day-ahead depend on whether it is peak or off-peak time. During the peak times, the battery is allowed to be discharged to its minimum limits (i.e., SOC min ) to avoid purchasing unnecessary energy at a high price tariff from the utility grid. The SOC is limited to its allowable limits during peak times as given by (10): During the off-peak times, the proposed algorithm considers day-2 forecast needs (i.e., E Day-f ), therefore (11) is used to ensure that the predicted required energy needed for day-2 peak time is stored in the BSS during the off-peak times: (11) 29360 VOLUME 10, 2022 Equation (12) is used to calculate the instantaneous power exchange with the battery for analysis purposes [1]: The instantaneous battery power is limited to the maximum allowable charge/discharge rating of the battery as follows [1]: B. SYSTEM CONSTRAINT In this part, four binary variables are created as state flags transition indications for the battery and utility grid. The four binary variables are B-disch , B-charg , import and export . The B-disch , B-charg are binary variables for battery discharge and charge modes, respectively. The import and export are binary variables for import from the utility grid and export to the utility grid, respectively.
The binary variables B-disch and B-charg are used to ensure that the battery is either charging or discharging at any time instant by using constraints (15) to (17) [1]: where B-disch (t) equals 1 indicate that the battery is discharging, B-charg (t) equals 1 indicate that the battery is charging. Constraints (18) and (19) are used to link between the battery power and the binary variables [1]: The binary variables of import (t) and export (t) ensure the building is only either importing or exporting power at any time instant using the constraints (20) -(23) are [1]: import (t) equals 1 if the building is importing power from the utility grid and equals 0 otherwise, and export (t) equals 1 if the building is exporting power to the utility grid and equals 0 otherwise. P G import (t) is the imported power from the utility grid, P G export (t) is the exported power to the utility grid, while P G max-import / P G max-export are the limits for the imported/exported powers from /to the utility grid.
To avoid discharging from the battery at the same time when the building is exporting its excess PV power to the utility grid, (24) is used [1]: where B-disch (t) equals 1 if the battery is discharging and equals 0 otherwise, export (t) equals 1 if the building exports power to the utility grid and equals 0 otherwise.

C. MIXED-INTEGER LINEAR PROGRAMMING
In this work, the MILP optimization technique and Gurobi Optimizer tool are used to solve the optimization problem in the MATLAB environment. The MILP is a mathematical optimization technique used to find the best solution for the objective function based on a set of constraints and variables [34], [35]. MILP problem can be solved by three different approaches, namely, Branch and Bound, Cutting Plane and Feasibility Pump. This study uses the Branch and Bound algorithm (also known as Tree search) [36]. The algorithm starts with the original MILP problem without the limitations, which is called the relaxation of the original LP problem. The Tree search algorithm is divided into three main steps: (1) branching stage, where a variable is picked and the problem is divided into two sub problems at this variable, (2) bounding stage, which solves the relaxed LP to find the best possible objective value for the node, (3) pruning stage, where if the subproblem is infeasible, the tree will not develop any further [37]. The flowchart in Fig. 3 illustrates how the optimization process is performed and how the constraints are met. As shown in Fig. 3, in order to find the optimal day-ahead setting for the BSS based on E Day-f , the cost function in (2) is optimized by these three steps. Firstly, the solution of the problem is obtained without any constraints (i.e., the relaxed LP). Secondly, the constraints are applied over the obtained results and the infeasible ones are removed. Finally, the variables which generate a feasible solution are used to generate more variables and then another iteration will be taken to solve the problem with those variables until the optimal solution is obtained. The feasible solution is a solution that meets all constraints, and the optimal solution is obtained when the best objective function value is achieved.

V. RESULTS AND DISCUSSION
In this section, the performance of the proposed EMS is compared with a recently published work [1] and the EMS that is currently used in the AOB. Especially, the operating costs and absolute net energy exchanged with the utility grid are compared to highlight the benefits of the proposed method. The algorithm in Fig. 2 is run for each day of the six months (from May to October 2019) with a sample time ( T ) of ten minutes.
There are several approaches to predict PV generation and load consumption, such as Artificial Neural Network [38], Differential Evolution [39] and PSO [40]. For the sake of generality, this study does not use a specific forecast method. Instead, the forecast error is accounted for by imposing normally distributed random numbers on the historical data [32]. The Mean Absolute Percentage Error (MAPE) of forecasted energy is assumed to be 30% over the six months.
In this study, two different tariff rates are considered according to the electricity utility company in the UK [41]. The peak rate applies from 8:00 AM to 8:00 PM, while the off-peak tariff rate is applied for the rest of the day. The tariff prices for the peak and off-peak are £0.1666/kWh and £0.1104/kWh, respectively. The PV export price is £0.055/kWh [4].
Recently, lithium-ion battery price has been reduced significantly [42], [43]. In this study, the CC B is 273£/kWh and the N cycle is 6000 [44].

A. PERFORMANCE COMPARISON
Figs. 4 and 5 show the battery performance for the EMS in [1] and the proposed EMS, respectively, for two test days (23 rd and 24 th of May 2019). The red and black lines represent SOC and P PV -P L , respectively. Note that in day-1, the generation is higher than demand most of the time and in day-2, the demand is higher than the generation most of the time. Fig. 4 shows that the battery is not charged with the available PV surplus power. Instead, the surplus power is exported to the utility grid to reduce the operating cost as energy is not required during day-1. This is because [1] does not use  day-2 forecast in the EMS. On day-2, the battery is charged during off-peak from the utility grid to supply the load during peak time. The main objective of the EMS in [1] is reducing the energy bill while considering C BSS . The main drawback of this method is that the optimization algorithm does not consider the day-2 generation and consumption forecast. This will result in higher operating costs and an increase in the energy exchange with the utility grid. In addition, this method is feeding the PV surplus power into the utility grid rather than charging the battery to supply load on the next day.
Unlike the EMS in [1], in the proposed system the battery is charged by the PV surplus power to increase the PV local consumption since it has prior knowledge about day-2 forecast energy, as illustrated in Fig. 5. In addition, the battery discharges energy stored from PV to avoid purchasing energy from the utility grid during peak times. This process reduces the absolute net energy exchanged and avoids purchasing unnecessary energy from the utility grid, which maximizes the use of PV power while considering the battery degradation costs. Fig. 6 shows the exported energy during peak time, for the six months. The blue, orange and yellow bars represent the proposed EMS in this work, the EMS adopted in [1] and the EMS currently in use in the AOB, respectively. As illustrated in Fig. 6, the proposed EMS enhances the PV self-consumption utilization by reducing the exported energy during peak time to the utility grid. Figs. 7 and 8 show imported energies during peak and offpeak times, respectively. The blue, orange and yellow bars represent the proposed EMS in this work, the EMS adopted in [1] and the EMS currently in use in the AOB, respectively. As shown in Figs. 7 and 8, the proposed EMS reduces the imported energies compared to the proposed method in [1] and the EMS in the AOB. Fig. 9 shows the total energy imported/exported from/to the utility grid for six months. The blue, orange and yellow bars represent the proposed EMS in this work, the EMS adopted in [1] and the EMS currently in use in the AOB, respectively, for six months. As shown in Fig. 9, the proposed EMS reduces the net energy exchanged with the utility grid as the absolute net energy exchanged is reduced by 121 % and 194%, compared to the EMS adopted in [1] and the EMS in the AOB, respectively. Table 1 compares the total operating costs of the proposed EMS with the EMS adopted in [1] and the EMS currently in use in the AOB for the six months. The proposed method reduces the energy bill by 46% and 37 % compared to EMS adopted in [1] and the EMS in the AOB. The proposed EMS uses the battery more than the EMS of [1], which reflects in higher degradation cost as illustrated in Table 1. This is simply because the proposed algorithm aimed to enhance the   self-consumption of PV power. In contrast, the energy bill in the proposed EMS is considerably less than that in [1], therefore, the battery degradation cost is covered from the energy bill saving. The proposed EMS reduces the total operating costs by 8% and 54% over six months compared to the EMS of [1] and the EMS of the AOB, respectively.

C. COMPARING DIFFERENT COST FUNCTIONS
The main objective of the proposed cost function of (2) is to minimize the absolute net energy exchanged with the utility grid while reducing the energy bill by considering the tariff prices. From a network operator viewpoint, a minimized net energy exchange might be more favorable since it reduces (1) the transmission losses, (2) the required central generation/storage systems. In other words, a minimized energy exchange can be used as a measure of energy independence of a prosumer, which in future networks, with a very high penetration of distributed generations, might be a definitive factor. With this motivation in mind, this sub-section investigates the impacts of using the objective function of (25) on the performance of the proposed EMS: where the E import and E export are the imported and exported energies from/to utility grid, respectively. Using the sum absolute values of the imported and exported energy as the cost function directly promotes reducing the net energy exchange, which is reflected in maximizing local consumption of the available RES. The results are compared in Table 2.
The results show that the cost function of (25) increases the energy bill by 7% compared to the cost function of (2). However, there is no difference in the absolute net energy exchanged when the cost function of (2) is compared with the cost function of (25). This demonstrates that the cost function of (2) can be considered as an optimal cost function that satisfies targets of minimizing the absolute net energy exchanged with the utility grid and the energy bill.

VI. CONCLUSION
The proposed EMS controls the battery effectively to (1) reduce the operating costs, (2) reduce the unnecessary energy exchange with the utility grid, (3) reduce the transmission losses, and the requirements for central generation systems. The proposed EMS can meet the demand during the peak tariff period by discharging the battery rather than importing from the utility grid through exploiting the next day-ahead forecast (i.e., day-2). The proposed algorithm reduces the daily energy costs and improves PV selfconsumption by reducing energy exchange with the utility grid.