## 2 Materials and Methods
### Two-Step Proposed EMS  
Performing energy management consists, in simple words, on actively deciding what resources of a MG are dispatched at every moment and with what level of power, in order to assure the proper functioning of the MG (the balance between production and consumption) and, in some cases, to favor a secondary objective(s). In order to do that, a system that makes decisions is required, as well as a hardware that allow the execution of those instructions. This process has to be performed at every moment (i.e., in real-time), otherwise the system risks suffering a blackout. However, sometimes it might be required to plan this real-time resources-dispatching in advance, and for a given window of time (e.g., in day-ahead energy markets). There also services that can only be offered if time-ahead scheduling is performed, as is the case of the grid-commitment service that is explained in Section 2.3.3. For the above reason, we decided to propose, in this work, a two-stage EMS strategy, where we separate the day-ahead scheduling from the real-time power balancing. This allows to favor two different objectives (services), one favored by the scheduling module (SCH) and the other favored by the real-time balancing module (BAL), as depicted in Figure 4.  
Figure 3: Electricité de France (EDF) tempo tariff fee schedule according to contracted power. In more detail, in a first stage of the EMS, an optimal scheduling is performed, where three different target objectives (TOs) are possible: energy cost, CO\({}_{2}\) emissions or grid peak-power. During the scheduling stage, only one TO is targeted (i.e., set as optimization objective), depending on the strategy chosen. By definition, all of the other services that are not being targeted are called Non-Target Objectives (NTOs). During this first scheduling stage, the grid-commitment service cannot be targeted. Table 1 presents a summary of the scheduling strategies along with their objective functions. In the second stage of the EMS, once the scheduling module has generated a given grid and battery profiles (i.e., scheduled profiles) -while favoring one of the possible target objectives-, it broadcasts the scheduled grid profile to a second module called: the balancing module (BAL). This module only targets one objective: the grid-commitment. This module runs in real-time and, therefore, is in charge of compensating the forecasting errors of the PV production, by following the rules described in Table 1. These rules are explicitly meant to favor the grid-commitment. This means that the BAL module will modify the scheduled battery profile or perform PV curtailment, in order to preserve the scheduled grid profile untouched, as long as physical constraints allow it (i.e., available capacity on the battery). This proposal is different to common multi-objective optimization EMS approaches, where the optimal compromise between the different objectives is simultaneously searched during the optimization execution [7; 35]. In contrast, our proposal targets a different objective (i.e., service) in each one of the two stages, (in a \"cascade\" approach), and using different methods (optimization-based, rule-based). That makes the optimization problem easier to formulate and solve, as compared to a multi-objective one. But the main reason why this approach was chosen, is because the