This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 1 Date of publication xxxx 00, 0000, date of current version xxxx 00, 0000. Digital Object Identifier 10.1109/ACCESS.2017.Doi Number Optimized Operation of Local Energy Community Providing Frequency Restoration Reserve HOOMAN FIROOZI1, HOSNA KHAJEH1, (Student Member, IEEE), AND HANNU LAAKSONEN1, (Member, IEEE) 1School of Technology and Innovations, Flexible Energy Resources, University of Vaasa, 65100 Vaasa, Finland Corresponding author: Hannu Laaksonen (e-mail: hannu.laaksonen@uwasa.fi) This work was undertaken as part of the FLEXIMAR project (novel marketplace for energy flexibility) with financial support provided by Business Finland (Grant No. 6988/31/2018) as well as Finnish companies. ABSTRACT In order to unlock the maximum flexibility potential of all levels in the power system, distribution-network-located flexible energy resources (FERs) should play an important role in providing system-wide ancillary services. Frequency reserves are an example of system-wide ancillary services. In this regard, this paper deals with the optimal operation of a local energy community (LEC) located in the distribution network. The LEC is proposed to participate in providing manual frequency restoration reserves (mFRR) or tertiary reserves. In addition, the community is supposed to have a number of electric vehicles (EVs) and a battery energy storage system (BESS) as FERs. The scheduling of the community, which is fully compliant with the existing balancing market structure, comprises two stages. The first stage is performed in day-ahead, in which the energy community management center (ECMC) estimates the amount of available flexible capacities for mFRR provision. In this stage, control parameters are deployed by the ECMC in order to control the offered flexibility of the BESS. In the second stage, the real-time scheduling of the community is performed for each hour, taking into account the assigned and activated amount of reserve power. The target of the real-time stage is to maximize the community’s profit. Finally, the model is implemented utilizing a case study considering different day-ahead control parameters of the BESS. The results demonstrate that the proposed control parameters adopted in the day-ahead stage considerably affect the real- time profitability of the LEC. Moreover, according to the simulation results, participating in the mFRR market can bring additional profits for the LEC. INDEX TERMS flexibility services, tertiary reserve, frequency restoration reserve, local energy community, flexible energy resources, mFRR, energy scheduling optimization. NOMENCLATURE Abbreviations aFRR Automatic frequency restoration reserve BCM Balancing capacity market BEM Balancing energy market BESS Battery energy storage system BSP Balancing service provider DBU Degree of BESS utilization DER Distributed energy resource DSO Distribution system operator ECMC Energy community management center EV Electric vehicle FCR Frequency containment reserve FER Flexible energy resource FFR Fast Frequency Reserve LEC Local energy community mFRR Manual frequency restoration reserve PV Photovoltaic SOC State of charge TSO Transmission system operator Sets t Index of hours {1,…,24} m Index of quarters (15-minute time slots) {1,…,4} s Index of scenarios i Index of EVs This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 First-stage Parameters 𝜋௧,௦ Probability of the scenario s at hour t 𝑃ா௏ Charging power of EVs [kW] 𝑁௧ ா௏ The number of EVs being charged at hour t 𝑁௧ ௣௟௨௚ The number of EVs which are supposed to be plugged in at hour t 𝑁௧ ௨௡௣௟௨௚ The number of EVs which are supposed to be unplugged at hour t 𝑃஻,௖௛,௠௔௫ The maximum charging power of the BESS [kW] 𝑃஻,ௗ௜௦,௠௔௫ The maximum discharging power of the BESS [kW] 𝐿௧ ௡௘௧,௙௢௥ Forecasted net load at hour t [kW] 𝑃௧ ௉௏,௙௢௥ Forecasted PV generation at hour t [kW] 𝜎௧ ௉௏ Standard deviation for the error of forecasted PV generation at hour t 𝑃௉௏,௜௡௦ Installed capacity of PV system [kW] 𝑃௧ ௅,௙௢௥ Forecasted load at hour t [kW] 𝜎௧ ௅ Standard deviation for the error of forecasted load at hour t ∆ℰ௧,௦ The error associated with the forecasted net-load at hour t [kW] 𝐶𝑎𝑝஻ Capacity of the BESS [kWh] 𝑆𝑂𝐶஻,௠௜௡ Minimum allowed state-of-charge of the BESS 𝑆𝑂𝐶஻,௠௔௫ Maximum allowed state-of-charge of the BESS 𝑆𝑂𝐶෪ ௧ ௠௜௡ Control parameters related to utilization of BESS’s capacity in the day-ahead stage 𝑆𝑂𝐶෪ ௧ ௠௔௫ Control parameters related to utilization of BESS’s capacity in the day-ahead stage 𝜂஻,௖௛ Efficiency of charging of the BESS 𝜂஻,ௗ௜௦ Efficiency of discharging of the BESS First-stage Variables 𝐹௧,௦ ௨௣ Upward offered flexibility at hour t for scenario s [kW] 𝐹௧,௦ ௗ௡ Downward offered flexibility at hour t for scenario s [kW] ℱ௧ ௨௣ Expected amount of upward flexibility offer at hour t [kW] ℱ௧ ௗ௡ Expected amount of downward flexibility offer at hour t [kW] 𝐶𝑎𝑝௧,௦ ௨௣ Auxiliary variable for available upward capacity at hour t for scenario s [kW] 𝐶𝑎𝑝௧,௦ ௗ௡ Auxiliary variable for available downward capacity at hour t for scenario s [kW] 𝑃௧,௦ ஻,௖௛,௘௦௧ Estimated power of charging the BESS at hour t for scenario s [kW] 𝑃௧,௦ ஻,ௗ௜௦,௘௦௧ Estimated power of discharging the BESS at hour t for scenario s [kW] 𝑆𝑂𝐶௧,௦ ஻,௘௦௧ Estimated state-of-charge of the BESS at hour t for scenario s 𝑢௧,௦ ஻,௘௦௧ Binary variable preventing the BESS from being charged and discharged simultaneously at hour t for scenario s Second-stage Parameters 𝐿௧,௠ ௡௘௧ Forecasted net-load in quarter m of hour t [kW] 𝜆௧ ௦௘௟௟ Retail prices of selling power to the grid at hour t [Cent/kWh] 𝜆௧ ௕௨௬ Retail prices of buying power from the grid at hour t [Cent/kWh] 𝒞஻ Operating cost of the BESS [cent/kWh] ℱ௧ ௨௣,௔௦ Assigned upward flexibility at hour t [kW] ℱ௧ ௗ௡,௔௦ Assigned downward flexibility at hour t [kW] 𝑢௧,௠ ௨௣ /𝑢௧,௠ ௗ௡ Binary parameters indicating the direction (upward/downward) of the assigned flexibility in quarter m of hour t Ψ௜ ௥௘௤ The minimum number of hours that EV i needs to be charged [hour] 𝑡௜ ௣௟௨௚ The hour at which EV i is supposed to be plugged in 𝑡௜ ௨௡௣௟௨௚ The hour at which EV i is supposed to be unplugged ∆𝑡௜ ௣௟௨௚௚௘ௗ The duration in which EV i is plugged in [hour] 𝐶𝑎𝑝௜ ா௏ Battery capacity of EV i [kWh] 𝑆𝑂𝐶௜,௧ିଵ,ସ ா௏,௔௖௧ Actual updated state-of-charge of EV i in 4th quarter of hour t-1 based on activated reserve data 𝑆𝑂𝐶௜,௧ିଵ,ସ ஻,௔௖௧ Actual updated state-of-charge of the BESS in 4th quarter of hour t-1 based on activated reserve data 𝐼௧ ௖௔௣ The income of the LEC obtained from provision of reserve capacity at hour t [cent/kWh] 𝐼௧ ௘௡,௨௣ The income of the LEC obtained from provision of upward reserve energy at hour t [cent/kWh] 𝐶௧ ௘௡,ௗ௡ The cost of the LEC incurred for purchasing downward reserve energy at hour t [cent/kWh] 𝜂ா௏ Efficiency of EVs’ batteries Second-stage Variables 𝑝̂௧,௠ ௜௡ Auxiliary variable for importing power to the LEC [kW] 𝑝̂௧,௠ ௢௨௧ Auxiliary variable for exporting power from the LEC [kW] 𝑃௧,௠ ௜௡ Imported power to the LEC [kW] 𝑃௧,௠ ௢௨௧ Exported power from the LEC [kW] 𝑃௧,௠ ஻,௖௛ Charging power of the BESS in quarter m of hour t [kW] 𝑃௧,௠ ஻,ௗ௜௦ Discharging power of the BESS in quarter m of hour t [kW] This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 𝑢௧,௠ ஻ Binary variable preventing the BESS from being charged and discharged simultaneously in quarter m of hour t 𝑢௜,௧,௠ ா௏ Binary variable indicating the charging status of EV i 𝑁௧,௠ ா௏,௥௧ The real-time number of EVs charging in quarter m of hour t 𝑆𝑂𝐶௜,௧,௠ ா௏ State-of-charge of the battery of EV i in quarter m of hour t 𝑆𝑂𝐶௧,௠ ஻ State-of-charge of the BESS in quarter m of hour t I. INTRODUCTION A. MOTIVATION Increasing the penetration of intermittent-based distributed energy resources (DERs) has led power system operators to deploy more flexibility services. In this way, system operators need to maintain the stability of the system at a specific threshold and increase the flexibility of the system using FERs. The flexibility of electrical systems could be defined as the continuous adjustability of the operating point of the network to accommodate the variations in predicted/unpredicted fluctuations of demand/generation [1]. Flexibility services can be provided by different FERs located in the transmission network and/or the distribution network. Exploiting the maximum flexibility potential of the power system requires the active utilization of FERs in all levels of the system [2]. Currently, transmission-network-connected FERs such as conventional generators are the only resources being deployed to satisfy system-wide (TSO-level) flexibility needs [3], [4]. In other words, flexibility needs of transmission networks are mostly met by transmission-network-connected FERs. However, the utilization of maximum flexible capacity of the whole system requires the contribution of FERs connected to different levels of the network. These levels include DSO- and TSO-levels [5]. Electric vehicles (EV), different types of energy storage such as batteries as well as household controllable appliances can be regarded as examples of distribution-network-located FERs [5]. System operators, including transmission system operators (TSO) as well as distribution system operators (DSO), deploy various types of flexibility services so as to fulfil their operational responsibilities. The flexibility services utilized by TSOs are commonly known as ancillary services [4]. These services are normally used to satisfy system-wide flexibility needs. This means that they are deployed mostly to maintain the system frequency at its predefined limit. The services include reserves, both spinning and non- spinning, which assist with the efficient operation of transmission networks. The ancillary services can be different depending on the characteristics and types of disturbances occurring in the power system [5], [6]. Currently in Nordic countries, frequency reserve services are categorized into primary reserves named frequency containment reserve (FCR), secondary reserves named automatic frequency restoration reserve (aFRR) and tertiary reserves named manual frequency restoration reserve (mFRR), which are deployed based on the system flexibility requirements. The FCR is a kind of reserve required to automatically respond to the real- time frequency deviation. This type of reserve is itself divided into two categories, namely frequency containment reserve for normal condition (FCR-N), which is utilized all the time, and frequency containment reserve for disturbance conditions (FCR-D). On the other hand, the aFRR is applied to automatically restore the balance, while the mFRR is used manually in case of outages, power-constrained occurrence related to cross-border connections as well as unexpected sustained activation of the aFRR [6], [7]. Moreover, a new kind of reserve market in the Nordic countries has been introduced in 2020, entitled fast frequency reserve (FFR), which can handle rapid frequency fluctuations during extremely low inertia situations (e.g. during summertime) [8]. As mentioned earlier, the main resources providing reserve services are currently conventional generators located in the TSO-level of networks. However, in the near future, the prevailing penetration of renewable energy resources would reduce the system’s inertia significantly. For this reason, the participation of distribution-network-located FERs is needed as well as in order to efficiently operate future power systems. B. LITERATURE REVIEW AND COMPARISON There exist previous studies that have assessed the participation of distribution-network-located FERs in providing TSO-level flexibility by taking part in reserve markets. In terms of storage-based resources, several studies analyzed the profitability and feasibility of the participation of different types of energy storage in reserve markets. For example, the authors of [9] propose a control policy for batteries so as to achieve near-optimal performance considering an offline controller which has complete information about the expected future status of the grid. Ref. [10] analyzed the contribution of energy storage for better management of the variability of demand and generation. The provision of aFRR services by a battery energy storage system (BESS) is evaluated in [11], in which the authors aim to estimate the potential revenue of the battery storage system in the balancing market. In [12], a price-maker storage system is proposed, to participate in pool-based markets including joint energy, reserve markets and balancing settlement. In this reference, the authors did not specify the exact type of balancing services as well as the reserve that the storage was proposed to provide. Finally, the participation of pumped hydro energy storage in day-ahead energy and performance- based regulation was examined in [13]. This service was designed for North American regulation markets. An electric vehicle (EV) aggregator has also been introduced as another reserve resource in the literature. For example, [14] proposes a novel bidding strategy for an EV aggregator aiming to provide TSO-level flexibility, by participating in reserve markets. The authors did not specify This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 the type of reserves procured from EVs. The authors of [15] developed a deterministic optimization problem in order to minimize the costs of purchasing energy and selling secondary reserves (spinning or regulation reserves in the United States [16], [17]). The study tries to schedule EVs based on the North American reserve markets formed for secondary reserve procurement. The provision of FCR services through an EV charging station is also presented by the authors of [18], where the study calculates the potential flexibility that can be procured by each charging cycle of EVs. In addition, some studies address the roles of distribution network aggregators in providing reserves. For instance, an aggregator of prosumers is proposed to take part in a joint day- ahead and reserve markets in [19]. This reference utilized a two-stage stochastic optimization model so as to support prosumers’ participation in the reserve market. In [20]–[22], various models are presented for a virtual power plant so as to maximize its profit by participating in energy and ancillary service markets. Furthermore, the aggregator introduced in [23] is capable of taking part in spinning reserve markets as well as peak-hours load reduction. The authors of [24] proposed a coordination scheme for aggregating consumers for the purpose of providing FCR services. Similarly, [25] developed a model for the utilization of grid-connected PV panels combined with a BESS, aiming to follow the regulation signals sent by the operator. Finally, a microgrid is regarded as a provider of reserve services and flexible ramping products in [26], seeking to maximize its total profits. Considering the existing literature, previous studies assessing the potential of distribution-network-located aggregated FERs have some shortcomings which need to be addressed in the future. For instance, in most of the above- mentioned studies, scheduling of FERs was not fully conducted based on the structure of real-world two-stage reserve markets in terms of market timing and technical aspects. In this light, for example, they do not consider whether the studied small-scale reserve unit is allowed to participate solely or whether it requires an aggregator as a broker. In addition, in most of the studies the authors do not differentiate between assigned reserve and activated reserve power, which can considerably affect the scheduling of FERs and thus affect the profitability of the reserve resource. TABLE I highlights the difference between the proposed method and the existing literature. It should be noted that the table includes those references which deal with the provision of TSO-level flexibility services through distribution- network-located resources. The first column of the table introduces the references. The second column states which kind of flexibility services are provided by the FERs. The third column assesses whether the research considers both day- ahead and real-time scheduling to include both capacity and energy of reserves. The fourth column analyzes whether the study takes into account the technical aspects and details of the existing reserve markets and whether the model is developed based on the existing reserve market models. Additionally, it assesses whether the relevant considerations related to the assigned and activated reserve are taken into account in the study. The fifth and sixth columns indicate whether they utilized the two important FERs in their models. TABLE I. Comparison of the proposed model with existing research Ref. Type of services for TSOs T w o-stage scheduling C om pliant w ith the existing m arkets B E SS as FE R E V s as FE R s [9] Frequency regulation - -  - [10] Frequency regulation - -  - [11] aFRR - -  - [12] Not specified - -  - [13] Performance-based regulation - -  - [14] Not specified  - -  [15] Secondary reserve  - -  [18] FCR -  -  [19] Secondary reserve  - -  [20] Spinning reserve - - - - [21] Spinning reserve & reactive power - - - - [22] Spinning reserve - -  - [23] Spinning reserve - - -  [24] FCR - - - - [25] Frequency regulation  - - - [26] Ramping products (US) -  - This Paper mFRR (tertiary reserve)     According to TABLE I, this paper offers the existing research some advantages, described below: 1. The distribution-network-located resource is considered to provide a type of ancillary service, which has not been regarded before. It offers mFRR services to the TSO. 2. It schedules its FERs in two stages (day-ahead and real- time) so as to take into account both reserve capacity and reserve power. 3. The model is in total compliance with the existing balancing market models in Nordic countries for providing mFRR services. The technical aspects and the difference between assigned and activated reserves are fully taken into account when scheduling the FERs. 4. The paper considers scheduling of two popular FERs, including BESS and EVs, at the same time. C. CONTRIBUTION In general, this paper presents a two-stage model for the participation of a PV-equipped LEC with EVs and a shared BESS for providing mFRR services. The first-stage This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 scheduling is run in day-ahead. In this stage, the LEC aims to estimate its flexible capacities and the offers which should be submitted for the provision of mFRR. In the real-time stage, the LEC is scheduled based on the assigned and activated reserve power determined in real-time. The main contribution of the paper is summarized as follows: 1) To the best of the authors’ knowledge, there exists no research assessing the participation of distribution- network-located resources in providing mFRR (tertiary reserve) services. Since each type of TSO-level reserve has a specific trading structure, along with specific technical considerations and activation time, the participation of reserve resources in each reserve market needs to be specifically analyzed. 2) The participation of a local energy community in reserve markets is not regarded in the existing studies. However, an LEC can be considered as one of the potent reserve providers by exploiting different-type distribution-network-located FERs and motivating members to manage their consumption. They can also share FERs so as to increase their profits. In this manner, the expenses of resources’ capital costs are shared between members while they can all benefit from the monetary income. For this purpose, this paper considers an LEC as a reserve provider whose members share a PV system as well as a BESS. There exists a number of EVs in the community, which can also contribute to the LEC’s flexibility provision. In this regard, the EV owners’ charging satisfaction is considered as well. 3) This paper considers control parameters related to the SOC of the BESS so as to manage the flexible capacity offered by the LEC in the day-ahead stage. Accordingly, different control parameters are calculated for the case study, and their impact on the community’s real-time operation and profitability are discussed. D. PAPER ORGANIZATION The rest of the paper is organized as follows. The model description is provided in Section II. Section III focuses on the problem formulation for both stages of this study. The case study and simulation results are discussed in Section IV. Finally, this study’s conclusion and possible future works is presented in Section V. II. MODEL DESCRIPTION Before describing the proposed two-stage model, the concept of an energy community should be defined and the markets’ considerations need to be introduced. A. ENERGY COMMUNITY A general definition of energy communities has been proposed by the literature, which refers to a group of members who voluntarily join a community. These members might appear in different forms, e.g. prosumers (proactive consumer) or/and consumers. Energy communities might also have a bulk energy storage system, wind turbine(s) and/or a PV system as shared assets between members. The aim of energy communities (i.e. its members’ aim) is to minimize energy costs along with maximizing the community’s revenue through trading energy with the grid as well as providing flexibility services to the networks [27]. There might be various types of energy communities in terms of members’ categories (e.g. residential, industrial, rural, etc.) or based on the physical distance between the members (e.g. local energy communities or distributed energy communities). Local energy communities are communities in which the members as well as the community’s assets are geographically close. In such communities, the energy produced locally is supposed to be consumed locally. In other words, there should be local proximity between prosumers and consumers [28]. Additionally, anyone from the local area can become a member of this community and can trade with other members within the community. Furthermore, the total cost and benefit of such trading must be shared between the members of the community [29]. Thus, the members will benefit from the synergy and cost-efficient outcomes of joining the community. There are various methods for the management of energy communities. Regarding this, a non-profit manager from amongst the community members should be nominated to be in charge of community management for monetary and technical considerations [30]. This paper considers a number of households as consumers who form a residential LEC. The community shares a BESS and there are also some EVs within the community, which contribute to increasing the LEC’s flexibility. In addition to these resources, the community is considered to have a shared PV system as a renewable energy resource. A non-profit community manager, through an energy community management center (ECMC), is in charge of the scheduling and operation of these resources in the community. The ECMC’s main goal is to increase the LEC’s profit by providing TSO-level flexibility to the grid and also to schedule the community’s flexible resources including EVs and the BESS. B. FLEXIBILITY SERVICES AND MARKET STRUCTURE The focus of this paper is on providing mFRR services. With regard to the Nordic balancing markets [31], [32], a balancing service provider (BSP) aggregates several reserve resources so as to provide suitable capacities for participation in balancing energy and capacity markets. In Finland, as an example of a Nordic country, the minimum capacity required for participation in mFRR service markets is 5 MW, which needs to consist of bids with a resolution of 1 MW [31]. The studied flexibility service, i.e. mFRR, is split into upward flexibility and downward flexibility services. In circumstances wherein systems require upward flexibility, the This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 TSO purchases power from the BSPs, whilst during time slots requiring downward flexibility, the TSO sells power to the BSPs [7]. The type of flexibility services required in each time slot depends on the TSO’s flexibility needs. Manual FRR services are traded in the balancing capacity market (BCM) and the balancing energy market (BEM). In the BCM, participants should submit their flexibility capacities before 11:00 a.m. of the day before delivery [31]. The TSO deploys the amount of capacity required and pays a capacity fee to the corresponding BSPs. However, participants can submit and modify their balancing energy bids in the BEM 45 minutes prior to delivery [31]. The BSP submits its bids for upward/downward regulation, the prices as well as other information regarding its reserve units to the BEM. Afterwards, the TSO decides on the assigned flexibility that should be provided by the BSPs, based on their offered prices, the type of required flexibility (upward or downward) and the amount of required flexibility in each time slot. As already mentioned, this paper considers a difference between the assigned flexibility and activated flexibility. Regarding this, the TSO determines the assigned flexibility of each BSP through the settlement of the BEM, while the activated amount of flexibility is specified at the exact moment of delivery based on the TSO’s real-time balancing requirements [31]. In other words, the TSO decides how much flexibility must be activated according to its instantaneous flexibility need. C. PROPOSED MODEL The proposed LEC, as a reserve unit, contributes to the provision of mFRR services. In order to enable participation of a small-scale LEC, the LEC’s flexibility offer should be sent to the BSP to be aggregated with those of the other reserve units and be submitted to the balancing markets. Fig. 1 depicts the main structure of the proposed LEC and its interaction with the grid and the BSP. As the figure illustrates, the LEC sells TSO-level flexibility through the BSP, and also trades energy with the upstream grid so as to fulfil its energy balance constraints. Regarding the structure of the balancing markets introduced in the previous section, the LEC as a reserve unit is supposed to be scheduled in two stages, each with different time horizons and granularity. In the first stage, the ECMC runs day-ahead 24-hour scheduling in order to estimate the flexible capacity of the LEC, which can be determined for each hour of the next day. The results should be submitted to the BSP before 11:00 a.m. of the day prior to delivery so that the BSP could be able to participate in the BCM and BEM with complete knowledge of its reserve units. FIGURE 1. The structure of the LEC and its interactions with the grid and BSP The second-stage scheduling, however, runs in real-time for the coming hour. Before this stage, the BSP participated in both BCM and BEM on behalf of its reserve units. Afterwards, the flexibility power that should be provided by the corresponding BSP was assigned by the TSO. Subsequently, the BSP determines the flexibility that needs to be provided by its reserve units. In this regard, the ECMC seeks to schedule the shared FERs to provide the assigned flexibility as well as maximizing the community’s real-time profit. Fig. 2 summarizes the proposed two-stage scheduling framework for the studied LEC and its interaction with the upstream entities. According to Fig. 2, the main interaction of the LEC is with the BSP in day-ahead and real-time horizons. The BSP is in charge of creating bidding strategies in order to participate in balancing markets (BCM and BEM) on behalf of its reserve units and assign the reserve power to each reserve unit. The main responsibility of the TSO regarding mFRR services is clearing the balancing markets, assigning the reserve power to each BSP according to its required frequency-based flexibility and activating the reserved power when needed. However, the main focus of this paper is on the optimized operation and scheduling of the LEC. Therefore, other issues such as the bidding strategy, reserve assignment, aggregation methods applied by the corresponding BSP and reserve market clearing performed by the TSO, as well as the calculation of the related flexibility need is not within the scope of this paper (see the grey blocks in Fig. 2). The proposed two-stage operation will be fully explained in Section III. III. PROBLEM FORMULATION The problem formulation of this paper includes two stages, which are explained in detail as follows. This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 FIGURE 2. Overview on the proposed scheduling of the LEC and the interactions with the BSP and TSO A. STAGE I: DAY-AHEAD FLEXIBILITY OFFER In this stage, the ECMC runs day-ahead scheduling aimed at estimating the LEC’s utmost capability to provide flexibility services for the 24 hours of the next day. The following factors are taken into account in the day-ahead stage: 1. EV owners in the LEC arrange their next-day exact plugged-in and plugged-out hours and submit it to the ECMC. Thus, the ECMC has the next-day temporal charging information of EVs. Note that it is assumed that EV charging is centrally controlled by the ECMC. In addition, for the sake of simplicity, they are assumed to be charged with constant power [33]. 2. The BESS can be monitored and controlled directly by the ECMC. Therefore, the ECMC has precise information regarding the BESS’s capacity and estimates the BESS’s next-day SOC based on its schedule. 3. The net-load of the LEC’s members is predicted hourly for the 24 hours of the next day. In order to capture the stochasticity of consumption load as well as the PV generation, the error of the forecasted net- load is here taken into consideration, which can be modelled a Gaussian distribution [34]. Note that the net-load of the LEC is defined as the difference between its aggregated consumers’ load and the LEC’s PV generation. Regarding the probability distribution model of the net-load’s forecasting error, different scenarios are considered for the first-stage schedule to consider the related uncertainties of the net-load originating from households’ stochastic behavior. 4. Finally, flexibility is estimated in a time horizon of 24 hours with one-hour time granularity. Hence, each time slot refers to one hour in the first-stage scheduling. For each time slot, the community offers its upward flexibility or/and downward flexibility power based on the community’s production surplus and the capability of its FERs (i.e. BESS and EVs) to change their consumption. In time slots during which the community’s surplus is positive it can submit its entire surplus as upward flexibility capacity. In contrast to this, the maximum capability of the community to increase its consumption can be considered as its downward flexible capacity. It is worth mentioning that according to the proposed strategy, the LEC may offer both downward and upward flexibility at one hour in the day-ahead stage if it simultaneously has a positive surplus and some available FERs that can increase their consumption. However, one type of offer (downward or upward) will be accepted and assigned in real-time. 1) FLEXIBILITY ESTIMATION As stated before, in the first stage the ECMC seeks to estimate the maximum upward and downward flexibility that can be offered for the 24 hours of the next day in order to submit this to the BSP for the provision of flexibility services. It is obvious that a requirement for participation in reserve markets like the mFRR is to declare capacity as reserve in previous day. Moreover, providing flexibility services is always much more profitable for the community, since the prices of balancing services is substantially higher than energy. Hence, the community should estimate the available flexibility that can be provided in the following day. The ECMC runs a stochastic optimization problem with the following objective function: 𝑚𝑎𝑥. ෍ ෍ 𝜋௧,௦(𝐹௧,௦ ௨௣ + 𝐹௧,௦ ௗ௡) ௧௦ (1) Equation (1) shows that the ECMC’s objective is to find the maximum upward and downward available flexibility which can be offered to the BSP for all of the considered scenarios and for all 24 hours of the following day. According to [7], regarding balancing energy markets (BEM), the price of selling upward flexibility is always greater than the price of selling power to the upstream grid or energy markets. In addition, the price of buying downward balancing flexibility is always lower than buying power from the upstream grid or energy markets. Hence, it can be concluded that participating in balancing markets is always beneficial to the LEC. Thus, in the day-ahead stage, the energy community is merely aiming to find the maximum flexible capacities which can be offered in balancing markets. The variable that helps to calculate the maximum upward flexible capacities of the LEC is defined by (2). 𝐶𝑎𝑝௧,௦ ௨௣ = 𝑃௧,௦ ஻,ௗ௜௦,௘௦௧−𝑁௧ ா௏,௘௦௧𝑃ா௏ − (𝐿௧ ௡௘௧,௙௢௥ + ∆ℰ௧,௦) ∀𝑡, ∀𝑠 (2) 𝐿௧ ௡௘௧,௙௢௥ = 𝑃௧ ௅,௙௢௥ − 𝑃௧ ௉௏,௙௢௥ ∀𝑡 (3) This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 According to (2), the upward flexibility of the LEC should be obtained from the LEC’s production surplus. The production surplus of the LEC is equal to the difference between the discharging power of the BESS and the aggregated values of net-load and EVs’ charging power. The net-load of the LEC at hour t could be obtained from (3). Equation (4) calculates the maximum downward flexible capacity which can be used for the provision of mFRR. 𝐶𝑎𝑝௧,௦ ௗ௡ = 𝑃௧,௦ ஻,௖௛,௘௦௧ + 𝑁௧ ா௏,௘௦௧𝑃ா௏ ∀𝑡, ∀𝑠 (4) The downward flexible capacity is known as the ability of the LEC’s FERs to increase their consumption. Since EVs and BESS are considered as the existing FERs in this study, charging these resources can be taken into account as LEC’s flexible consumption. Hence, the charging power of the mentioned resources can be considered as the LEC’s available downward flexibility for scenario s and time slot t as stated in (4). Equations (5) and (6) indicate that the charging and discharging power of the BESS cannot exceed their maximum rate, respectively. The binary variable 𝑢௧,௦ ஻,௘௦௧ in (5) and (6) is employed in order to prevent the BESS from being charged and discharged simultaneously. This variable is considered to be 1 when the BESS is in a charging state, otherwise it is equal to 0. 𝑃௧,௦ ஻,௖௛,௘௦௧ ≤ 𝑃஻,௖௛,௠௔௫𝑢௧,௦ ஻,௘௦௧ ∀𝑡, ∀𝑠 (5) 𝑃௧,௦ ஻,ௗ௜௦,௘௦௧ ≤ 𝑃஻,ௗ௜௦,௠௔௫൫1 − 𝑢௧,௦ ஻,௘௦௧൯ ∀𝑡, ∀𝑠 (6) Moreover, the net-load error is assumed to be represented by a Gaussian distribution denoted by ∆ℰ௧(𝜇௧ , 𝜎௧), where 𝜇௧ is the mean value for error of forecast and 𝜎௧ is the related standard deviation. These are obtained as follows [34]: 𝜎௧ = ට(𝜎௧ ௉௏)ଶ + (𝜎௧ ௅)ଶ ∀𝑡 (7) 𝜎௧ ௉௏ = 0.2𝑃௧ ௉௏,௙௢௥ + 0.02𝑃௉௏,௜௡௦ ∀𝑡 (8) 𝜎௧ ௅ = 𝑘 100 𝑃௧ ௅,௙௢௥ ∀𝑡 (9) Equation (7) shows that the standard deviation of the net- load is obtained from consumption demand and is related to the PV located in the LEC. The standard deviation of PV production is defined in (8) while the standard deviation of the total consumption load of the community is shown in (9). In (9), k is a function of the accuracy of load prediction [34]. The community can offer upward flexibility when it has a positive upward flexible capacity (i.e. the LEC’s production surplus). Similarly, downward flexibility can be ascertained when the downward flexible capacity experiences a positive value, as stated by (10) and (11), respectively. 𝐹௧,௦ ௨௣ = ൜ 𝐶𝑎𝑝௧,௦ ௨௣ 𝐶𝑎𝑝௧,௦ ௨௣ ≥ 0 0 else ∀𝑡, ∀𝑠 (10) 𝐹௧,௦ ௨௣ = ൜ 𝐶𝑎𝑝௧,௦ ௗ௡ 𝐶𝑎𝑝௧,௦ ௗ௡ ≥ 0 0 else ∀𝑡, ∀𝑠 (11) Since EVs are supposed to submit their plugged-in and plugged-out charging hours beforehand, the number of EVs being charged during each hour can be obtained simply by using (12). 𝑁௧ ா௏ = 𝑁௧ିଵ ா௏ + 𝑁௧ ௣௟௨௚ − 𝑁௧ ௨௡௣௟௨௚ ∀𝑡 (12) Equation (12) states that the number of charging EVs at hour t is equal to the number of EVs charged in the previous hour plus the number of those beginning to charge at hour t minus the number of EVs which are supposed to be unplugged at hour t. There exist constraints related to the operation of the BESS, which are indicated by (13) and (14). Equation (13) relates the estimated SOC of the BESS to its charging and discharging power. This constraint can also indicate the variation regarding the state of energy of the BESS. Equation (14) restricts the maximum and minimum permissible values of the estimated SOC, which implicitly limits the energy stored in the BESS as well. 𝑆𝑂𝐶௧,௦ ஻,௘௦௧ = 𝑆𝑂𝐶௧ିଵ,௦ ஻,௘௦௧ + Δ𝑡 𝐶𝑎𝑝஻ (𝜂஻,௖௛𝑃௧,௦ ஻,௖௛,௘௦௧ − 𝑃௧,௦ ஻,ௗ௜௦,௘௦௧ 𝜂஻,ௗ௜௦ ) ∀𝑡, ∀𝑠 (13) 𝑆𝑂𝐶෪ ௧ ௠௜௡ ≤ 𝑆𝑂𝐶௧,௦ ஻,௘௦௧ ≤ 𝑆𝑂𝐶෪ ௧ ௠௔௫ ∀𝑡, ∀𝑠 (14) The ECMC is proposed to adopt two control parameters, i.e. 𝑆𝑂𝐶෪ ௧ ௠௜௡ and 𝑆𝑂𝐶෪ ௧ ௠௔௫ , to control the amount of BESS’s capacity deployed for provision of flexibility services. In day- ahead scheduling, there might exist some uncertainties related to the activation of balancing services, its direction (i.e. upward or downward) and those associated with forecasting PV production and demand. Therefore, the ECMC may decide to save some part of its BESS’s capacity and deploy it in real- time schedules so as to avoid the risk of penalty costs related to not providing the assigned flexibility in real-time. For this purpose, the mentioned control parameters are employed to limit the day-ahead utilization of the BESS’s capacity in providing TSO-level flexibility services. These parameters should be determined within a range introduced as follows: 𝑆𝑂𝐶஻,௠௜௡ ≤ 𝑆𝑂𝐶෪ ௧ ௠௜௡ ≤ 𝑆𝑂𝐶஻,௠௔௫ ∀𝑡 (15) 𝑆𝑂𝐶஻,௠௜௡ ≤ 𝑆𝑂𝐶෪ ௧ ௠௔௫ ≤ 𝑆𝑂𝐶஻,௠௔௫ ∀𝑡 (16) 𝑆𝑂𝐶෪ ௧ ௠௜௡ ≤ 𝑆𝑂𝐶෪ ௧ ௠௔௫ ∀𝑡 (17) In (15) and (16), the value of 𝑆𝑂𝐶஻,௠௜௡ and 𝑆𝑂𝐶஻,௠௔௫ indicate the lower and upper limits of state-of-charge, where their values depend on the type of BESS. Equation (17) shows This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 that the selected value for the lower controller of state-of- charge, i.e. 𝑆𝑂𝐶෪ ௧ ௠௜௡, must be smaller than the upper controller of state-of-charge, i.e. 𝑆𝑂𝐶෪ ௧ ௠௔௫ , at all times. Taking these constraints into account, if the gap between the adopted 𝑆𝑂𝐶෪ ௧ ௠௜௡ and 𝑆𝑂𝐶෪ ௧ ௠௔௫ decreases, it means that the ECMC prefers to offer a lower amount of its BESS’s flexible capacity for reserve services and save a portion of its flexibility for the real-time scheduling (see Fig. 3). Fig. 3 indicates the amount of BESS’s capacity deployed for flexibility offers in day- ahead. FIGURE 3. An illustration of the BESS utilization scheme in day-ahead according to the proposed control parameters Accordingly, the expected amount of upward and downward flexibility in each time slot, which is supposed to be offered to the BSP, is obtained from (18) and (19). ℱ௧ ௨௣ = ෍ 𝜋௧,௦𝐹௦,௧ ௨௣ ௦ ∀𝑡 (18) ℱ௧ ௗ௡ = ෍ 𝜋௧,௦𝐹௦,௧ ௗ௡ ௦ ∀𝑡 (19) After offering the total downward and upward flexible capacity by the ECMC, the BSP will then participate in balancing markets (BCM and BEM) by aggregating the flexibility offers of its reserve units. B. STAGE II: REAL-TIME OPERATION AND SCHEDULING Before the real-time stage, the TSO determines the power that should be provided by the BSP. In fact, the BSP has already participated in balancing markets and the results of the market settlement are specified in real-time. Afterwards, the BSP determines the amount of flexibility that should be provided by the LEC based on its day-ahead offer. Regarding this information, the manager of the community needs to schedule its FERs so as to achieve the following targets: 1. Fulfil the assigned power for mFRR provision 2. Maximize the total real-time monetary profits of the LEC In this manner, this paper considers that the ECMC schedules the community’s FERs for the next hour regarding four temporal quarters (15-minute timeslots), based on the assigned values of flexibility. Therefore, the time horizon and time granularity of the scheduling would be one hour and 15- minutes, respectively. The following factors are also considered in this stage: a. EV owners are assumed to adhere to their day-ahead plan. They plug in and unplug their vehicles at the exact hours they have stipulated beforehand, since they have accepted the content of the intra-community rules and must not violate their predetermined agreement signed with the community manager. In this regard, based on EV owners’ desires and needs, the ECMC can schedule the vehicles for the next four quarters. b. EV owners are supposed to submit the minimum number of hours that they want their vehicles to be charged. This constraint is applied in order to take into account the EV owners’ charging satisfaction. c. It is assumed that the ECMC monitors the real-time state of the FERs. Indeed, the ECMC updates the information regarding the SOC of the BESS and EVs at the end of each hour, based on the activated reserve. This information will be deployed for scheduling FERs for the next hour. d. PV power generation as well as demand forecasts are updated hourly. Since predictions with very short-time horizons (i.e. one hour) are relatively more accurate than, e.g. day-ahead forecasting, the results of PV/demand predictions are considered deterministic and not to be subjected to any uncertainties. e. After fulfilling the assigned value of TSO-level flexibility services, the ECMC trades the surplus power with the upstream grid through a DSO or a retailer. 1) LEC SCHEDULING According to the assumptions above, the ECMC runs an optimization problem with the objective of maximizing the community’s real-time profit, denoted by (20). Profit is defined by (21). In addition, (22) denotes the income or cost obtained from the LEC’s participation in reserve provision. By using the objective function indicated by (20), the optimization problem seeks to find a compromise between flexibility obtained from its FERs and profits of the LEC. 𝑚𝑎𝑥. ෍ 𝑃𝑟𝑜𝑓𝑖𝑡 ௧,௠ ௥௘௔௟ି௧௜௠௘∆𝑚 ௠ ∀𝑡 (20) 𝑃𝑟𝑜𝑓𝑖𝑡 ௧,௠ ௥௘௔௟ି௧௜௠௘ = 𝐼𝐶௧,௠ ௙௟௘௫ ᇣᇤᇥ ௑ + 𝑃௧,௠ ௢௨௧𝜆௧ ௦௘௟௟ ᇣᇧᇧᇤᇧᇧᇥ ூ௡௖௢௠௘ ூூ − 𝑃௧,௠ ௜௡ 𝜆௧ ௕௨௬ ᇣᇧᇤᇧᇥ − ஼௢௦௧ ூூ 𝒞஻൫𝑃௧,௠ ஻,ௗ௜௦ + 𝑃௧,௠ ஻,௖௛൯ᇣᇧᇧᇧᇧᇧᇤᇧᇧᇧᇧᇧᇥ ஼௢௦௧ ூூூ ∀𝑡, ∀𝑚 (21) 𝐼𝐶௧,௠ ௙௟௘௫ = 𝐼௧ ௖௔௣ + 𝐼௧ ௘௡,௨௣ − 𝐶௧ ௘௡,ௗ௡ ∀𝑡, ∀𝑚 (22) On the left side of (21), 𝑃𝑟𝑜𝑓𝑖𝑡 ௧,௠ ௥௘௔௟ି௧௜௠௘ indicates the total profit of the LEC in real-time. On the right side of this equation, X represents the income or cost due to the provision of capacity and energy related to mFRR services. According to (22), the LEC receives a fixed monetary amount which is paid for offering flexibility capacities (both upward and downward), denoted by 𝐼௧ ௖௔௣. In fact, this income is obtained by the participation of the BSP in the BCM. In addition, the LEC receives the income for selling upward This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 energy (𝐼௧ ௘௡,௨௣) and incurs the cost for purchasing downward energy (𝐶௧ ௘௡,ௗ௡) from the BEM. In this manner, the BSP plays the role of an intermediary by participating in the BCM and BEM. The remaining terms of (21) are as follows. The term Income II denoted the revenue resulting from selling energy to the upstream grid through the DSO or the retailer. The term 𝐶𝑜𝑠𝑡 𝐼𝐼 denotes the cost of purchasing energy from the grid. The last term, 𝐶𝑜𝑠𝑡 𝐼𝐼𝐼, refers to the operating cost of charging and discharging the BESS. It has to be mentioned that 𝒞஻is the operating costs of charging/discharging the BESS, which are considered constant over the studied time and obtained as follows [35]. 𝒞஻ = 𝑅𝐶஻ 𝐶𝑎𝑝஻ × 𝐷𝑂𝐷஻ × 𝑅𝐿஻ (23) Where 𝐷𝑂𝐷஻ indicates depth of discharge of the BESS. The rated lifetime and the replacement cost of the BESS are denoted by 𝑅𝐿஻ and 𝑅𝐶஻, respectively. The main priority of the LEC’s real-time scheduling is to provide the assigned flexibility services, i.e. ℱ௧ ௨௣,௔௦and ℱ௧ ௗ௡,௔௦. However, to satisfy power balance constraint within the LEC, the ECMC should trade surplus power with the upstream grid. Accordingly, (24) denotes the balance equations, when the LEC provides upward and downward flexibility services. (24) ൝ 𝐿௧,௠ ௡௘௧ + 𝑃௧,௠ ஻,௖௛ + 𝑁௧,௠ ௖௛ 𝑃ா௏ = ℱ௧ ௗ௡,௔௦ + 𝑝̂௧,௠ ௜௡ if 𝑢௧,௠ ௨௣ = 0 −𝐿௧,௠ ௡௘௧ + 𝑃௧,௠ ஻,ௗ௜௦ − 𝑁௧,௠ ௖௛ 𝑃ா௏ = ℱ௧ ௨௣,௔௦ + 𝑝̂௧,௠ ௢௨௧ if 𝑢௧,௠ ௗ௡ = 0 In (24), 𝑢௧,௠ ௨௣ and 𝑢௧,௠ ௗ௡ are binary parameters which have been determined by the BSP according to the market settlement results of the BEM. In other words, these parameters provide information on whether the TSO requires downward or upward flexibility services. According to (24), in the case of providing downward flexibility, 𝑢௧,௠ ௨௣ is equal to 0 and the consumption power of the net-load and the charging power of the BESS and EVs is supplied by the imported power from the upstream grid, as well as the downward flexibility power bought from the BEM. Similarly, in the case of providing upward flexibility, the positive power surplus of the LEC is sold to the upstream grid after fulfilling the assigned upward flexibility. It should be noted that ℱ௧ ௗ௡,௔௦ and ℱ௧ ௨௣,௔௦ are parameters whose values have been specified by the BSP. If 𝑝̂௧,௠ ௜௡ , which is obtained from (24), has a positive value, this means that the LEC is not self-sufficient and the required energy should be supplied by the grid. The imported power then would be equal to 𝑃௧,௠ ௜௡ . Similarly, if 𝑝̂௧,௠ ௢௨௧ has a positive value, this means that there exists some production surplus that should be sold to the grid. Thus, the exported power equals 𝑃௧,௠ ௢௨௧ , as denoted by (25) and (26). 𝑃௧,௠ ௜௡ = ൜ 𝑝̂௧,௠ ௜௡ 𝑝̂௧,௠ ௜௡ > 0 0 else ∀𝑡, ∀𝑚 (25) 𝑃௧,௠ ௢௨௧ = ൜ 𝑝̂௧,௠ ௢௨௧ 𝑝̂௧,௠ ௢௨௧ > 0 0 else ∀𝑡, ∀𝑚 (26) In the proposed real-time scheduling, each EV is being scheduled to maximize the community’s profit. Equation (27) – (31) are constraints related to charging the community’s EVs. It should be highlighted that all EVs are supposed to be charged with a constant power rate, denoted by 𝑃ா௏. 𝑁௧,௠ ா௏ = ෍ 𝑢௜,௧,௠ ா௏ ௜ ∀𝑡, ∀𝑚 (27) ෍ 𝑢௜,௧,௠ ா௏ ௠ ≥ 4Ψ௜ ௥௘௤ ∆𝑡௜ ௣௟௨௚௚௘ௗ ∀𝑖, ∀𝑡 ∈ [𝑡௜ ௣௟௨௚ , 𝑡௜ ௨௡௣௟௨௚ ] (28) 𝑆𝑂𝐶௜,௧,௠ ா௏ = ⎩ ⎪ ⎨ ⎪ ⎧𝑆𝑂𝐶௜,௧ିଵ,ସ ா௏,௔௖௧ + 𝜂ா௏𝑃ா௏∆𝑚 𝐶𝑎𝑝௜ ா௏ 𝑢௜,௧,௠ ா௏ if 𝑚 = 1 𝑆𝑂𝐶௜,௧,௠ିଵ ா௏ + 𝜂ா௏𝑃ா௏∆𝑚 𝐶𝑎𝑝௜ ா௏ 𝑢௜,௧,௠ ா௏ else ∀𝑖, ∀𝑡, ∀𝑚 (29) 𝑆𝑂𝐶௜,௧,௠ ா௏ ≤ 𝑆𝑂𝐶ா௏,௠௔௫ ∀𝑖, ∀𝑡, ∀𝑚 (30) 𝑢௜,௧,௠ ா௏ = 0 ∀𝑖, ∀𝑚, ∀𝑡 ∉ ൣ𝑡௜ ௣௟௨௚ , 𝑡௜ ௨௡௣௟௨௚ ൧ (31) In (27), (29) and (30), 𝑢௜,௧,௠ ா௏ is a binary decision variable which determines the charging status of EV i during quarter m of hour t. This variable is equal to 1 if EV i is being charged during quarter m of hour t. Otherwise, it equals 0. Accordingly, (27) expresses that the total number of EVs that are being charged during time slot m of hour t is obtained through the summation of the binary variables related to the charging status of all EVs within the LEC. Equation (28) determines the number of quarters that an EV needs to be charged during a given hour. As previously stated, in the real-time stage, the scheduling time granularity is 15 minutes (one quarter) and the scheduling time horizon is one hour. Therefore, considering the one-hour time horizon, if an EV needs to be charged for Ψ௜ ௥௘௤ hour during ∆𝑡௜ ௣௟௨௚௚௘ௗ hours, the EV should be charged at least ସஏ೔ ೝ೐೜ ∆௧ ೔ ೛೗ೠ೒೒೐೏ quarters during one hour (four quarters). To elaborate this constraint, consider that EV i requests to be charged for at least one hour (i.e. Ψ௜ ௥௘௤ = 1). This EV, for instance, was plugged in at 8:00 and unplugged at 12:00, so it was plugged in for four hours (i.e. ∆𝑡௜ ௣௟௨௚௚௘ௗ = 4). Therefore, according to constraint (28), this EV should be charged at least one quarter in each hour during for which the vehicle is plugged. Through the ECMC, the community manager decides how the EVs should be charged in the plugged in periods. In order to keep all parties satisfied, it is feasible to spread the charging quarters over the plugging time, rather than charging them in a limited period. This could reduce possible peak loads during some hours. This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 The constraints related to EVs’ battery SOC are presented by (29) and (30). It should be mentioned that the 4th quarter of hour (t-1) is followed by the 1st quarter of hour t, as explained in (29). Regarding the first equation of (29), the EVs’ SOC in the 1st quarter of each hour should be determined based on its actual value in the 4th quarter of the previous hour, because the actual value of EVs’ SOC may not be equal to that scheduled in the previous hour. Since the activated and assigned values of reserve power may not be equal, the scheduled values of EVs’ SOC need to be replaced with the actual values. However, for the 2nd to 4th quarters of each hour, the values of EVs’ SOC could be obtained based on their scheduled values in the previous quarter, as explained in the second equation of (29). Equation (30) restricts the maximum value of the SOC of EVs’ batteries. Finally, (31) ensures that the EVs will only be charged during the hours in which they are plugged in, meaning that they should be charged in a range which is part of the EV’s plugged-in/plugged-out time window. Otherwise, the optimization solver should assign a zero value to the charging status of the EV. In the following, the constraints related to the BESS are presented. Equation (32) and (33) elaborate the constraints associated with the SOC of the BESS. In (32) and (33), if we multiply both sides of the BESS’s capacity, we will have the related constraints of the BESS’s state-of-energy. Again, the scheduled value of the SOC for the previous hour (t-1) should be replaced with the actual SOC of the BESS. This value is utilized to schedule the BESS at hour t. The BESS will be charged/discharged only when needed. This need is the amount of energy required for balancing purposes, which is announced by the BSP/TSO. However, the BSP/TSO always asks for flexibility within the LEC’s capability. The TSO would not ask for more than the LEC can offer. Finally, (34) and (35) restrict the charging and discharging power of the BESS, respectively [36], along with the fact that the BESS is not allowed to be charged and discharged simultaneously, with the help of binary variable 𝑢௧,௠ ஻ . 𝑆𝑂𝐶௧,௠ ஻ = ⎩ ⎪⎪ ⎨ ⎪⎪ ⎧𝑆𝑂𝐶௧ିଵ,ସ ஻,௔௖௧ + ൭𝜂஻,௖௛𝑃௧,௠ ஻,௖௛ − 𝑃௧,௠ ஻,ௗ௜௦ 𝜂஻,ௗ௜௦ ൱ Δ𝑚 𝐶𝑎𝑝஻ if 𝑚 = 1 ∀𝑡, ∀𝑚 𝑆𝑂𝐶௧,௠ିଵ ஻ + ൭𝜂஻,௖௛𝑃௧,௠ ஻,௖௛ − 𝑃௧,௠ ஻,ௗ௜௦ 𝜂஻,ௗ௜௦ ൱ Δ𝑚 𝐶𝑎𝑝஻ else (32) 𝑆𝑂𝐶஻,௠௜௡ ≤ 𝑆𝑂𝐶௧,௠ ஻ ≤ 𝑆𝑂𝐶஻,௠௔௫ ∀𝑡, ∀𝑚 (33) 𝑃௧,௠ ஻,௖௛ ≤ 𝑢௧,௠ ஻ 𝑃஻,௖௛,௠௔௫ ∀𝑡, ∀𝑚 (34) 𝑃௧,௠ ஻,ௗ௜௦ ≤ ൫1 − 𝑢௧,௠ ஻ ൯𝑃஻,ௗ௜௦,௠௔௫ ∀𝑡, ∀𝑚 (35) The ECMC runs this optimization problem considering (20)–(35) for each hour, to schedule its FERs including the BESS and EVs as well as its trading power with the upstream grid, aiming to maximize the community’s real-time profit. Before starting the next-hour scheduling, the SOC of the BESS and EVs for the previous hour, i.e. 𝑆𝑂𝐶௧ିଵ,ସ ஻,௔௖௧ and 𝑆𝑂𝐶௜,௧ିଵ,ସ ா௏,௔௖௧, are updated based on the real data resulted from the activated mFRR. Thereafter, the real-time scheduling is run for the next hour (next four quarters), accordingly. It should be mentioned that decreasing the charging rate of the BESS as flexibility-up, or increasing the discharging rate of the BESS as flexibility-down, could be considered as flexibility, which actually happen in real-time operation of the BESS in the process of flexibility provision. However, counting on them as the capacity for participation in the mFRR market would not be a wise choice. For instance, in a case where we are dealing with the constant BESS’s power rates, counting on the above-mentioned strategy for flexibility provision would not be generally applicable. Moreover, the change in the power rate of the BESS might not satisfy the offered flexibility. IV. NUMERICAL STUDIES A. CASE STUDY The case study consists of a hypothetical LEC with 50 households. This community has a 100kW PV system as well as FERs, including a 50kW/200kWh (Vanadium Redox Flow) BESS and 10 EVs. The information on EVs’ plugged- in/plugged-out status and the EVs’ battery capacity can be found in TABLE II. TABLE II. Information on the EVs owned by the community members EV No. 𝐶𝑎𝑝ா௏ (kWh) 𝑡௣௟௨௚ 𝑡௨௡௣௟௨௚ 1 40 08:00 10:00 2 12 08:00 11:00 3 11.6 10:00 13:00 4 11.6 08:00 10:00 5 40 12:00 15:00 6 12 15:00 17:00 7 12 16:00 18:00 8 40 17:00 19:00 9 11.6 17:00 19:00 10 12 17:00 19:00 It is also assumed that EVs request to be charged at least for two 15-minute quarters. Moreover, the information related to the characteristics of the BESS in the simulation studies is given in TABLE III [37]. TABLE III. Characteristics of the shared BESS in the community Technology Vanadium R.F. Price (€/kWh) 100 Depth of Discharge (%) 60 Rated Lifetime (cycles) 12000 Capacity (kWh) 200 Max. Charging/Discharging Rate (kW) 50 Charging/Discharging Efficiency 0.8 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 The forecasted day-ahead as well as actual values of demand and solar generation are depicted in Fig. 4. The pattern of solar irradiation is based on the historical data for July 7, 2019 in Finland [8]. The forecasting error of PV generation in the day-ahead study is represented by an independent normal distribution with a zero mean value and a 10% standard deviation. Similarly, the forecasting error of the demand load is also modelled with a zero mean value and a 2% standard deviation. FIGURE 4. Actual and forecasted values of PV generation and demand B. SIMULATION RESULTS The simulation in this paper was executed on a laptop with an Intel Core-i5 6200U 2.3GHz CPU and 16GB of RAM. The optimization algorithms were implemented by using the well- known GAMS programming software. 1) DAY-AHEAD FLEXIBILITY OFFER In order to conduct the introduced stochastic study, 1000 scenarios were produced by utilizing Monte Carlo simulation for PV generation and load demand of each hour. Afterwards, the optimization problem defined in (1)–(19) was solved for the LEC introduced in this section. It is noticeable that a linearization technique was utilized, similar to the one deployed in [38], so as to linearize constraints (10) and (11) (see APPENDIX). The total daily values of upward and downward flexibility offered to the BSP are calculated based on different SOC-based control parameters and the results are illustrated in TABLE IV. It should be noted that the control parameters are given as constant for 24 hours. In addition, the degree of BESS utilization (DBU) for offering flexibility is calculated for each case using the following equation (34): 𝐷𝐵𝑈௧ = 𝑆𝑂𝐶෪ ௧ ௠௔௫ − 𝑆𝑂𝐶෪ ௧ ௠௜௡ 𝑆𝑂𝐶௠௔௫ − 𝑆𝑂𝐶௠௜௡ × 100 (34) Regarding TABLE IV, all of the considered cases lead to three pairs of total upward and downward flexibility offers, i.e. (∑ ℱ௧ ௨௣ ௧ ∑ ℱ௧ ௗ௡ ௧ ), which are (583.9 780.5), (133.9 180.5) and (83.9 80.5). In light of this conclusion, we narrowed down all considered cases into three groups based on the values of available flexibility, namely G1, G2 and G3. These groups are illustrated by three different colors in TABLE IV. The hourly upward and downward flexibility of these groups have been calculated and the results are depicted in Fig. 5 and Fig. 6, respectively. TABLE IV. The results of total daily flexibility offers in day-ahead, based on different BESS control parameters Case No. Control Parameters Total Daily Upward Flexibility Offer (kW) Total Daily Downward Flexibility Offer (kW) DBU (%) 𝑆𝑂𝐶෪ ௧ ௠௜௡ 𝑆𝑂𝐶෪ ௧ ௠௔௫ 1 0.2 0.8 583.9 780.5 100 2 0.3 0.8 583.9 780.5 83 3 0.4 0.8 133.9 180.5 67 4 0.5 0.8 83.9 80.5 50 5 0.2 0.7 583.9 780.5 83 6 0.3 0.7 83.9 80.5 67 7 0.4 0.7 83.9 80.5 50 8 0.5 0.7 83.9 80.5 33 9 0.2 0.6 133.9 130.5 67 10 0.3 0.6 83.9 80.5 50 11 0.4 0.6 83.9 80.5 33 12 0.5 0.6 83.9 80.5 17 13 0.2 0.5 133.9 130.5 50 14 0.3 0.5 83.9 80.5 33 15 0.4 0.5 83.9 80.5 17 G1 G2 G3 According to TABLE IV, in general, the amount of upward flexibility and downward flexibility offered to the BSP decreases when 𝑆𝑂𝐶෪ ௧ ௠௜௡ increases. However, this effect does not seem to be significant when the other control parameter, i.e. 𝑆𝑂𝐶෪ ௧ ௠௔௫, has a lower value. Although the higher value of 𝑆𝑂𝐶෪ ௧ ௠௜௡ leads to a lower amount of offered flexibility for cases 1, 2, 3 and 4, this trend does not strongly continue for the other cases. For example, increasing 𝑆𝑂𝐶෪ ௧ ௠௜௡ does not change the flexibility offer of cases 6, 7 and 8. This is due to the fact that the amount of 83.9 kW for upward flexibility and 80.5 kW for downward flexibility mainly stem from other sources of production (e.g. the surplus PV production of the LEC and EVs). Hence, decreasing the capacity of the BESS does not affect these values. Similarly, TABLE IV indicates that, in general, reducing control parameter 𝑆𝑂𝐶෪ ௧ ௠௔௫ decreases the estimated amount of offering upward and downward flexibility. However, in some cases it does not considerably affect the amount of flexibility. As can be seen in this table, the higher amount of offered flexibility is provided by case 1, 2 and 5, with high DBU and pairs of control parameters, i.e. (𝑆𝑂𝐶෪ ௧ ௠௜௡ 𝑆𝑂𝐶෪ ௧ ௠௔௫), which are equal to (0.2 0.8), (0.3 0.8) and (0.2 0.7). In terms of offering higher flexibility, the second-ranked cases are 3, 9, and 13 with control parameters (0.4 0.8), (0.2 0.6), and (0.2 0.5). In comparison, the rest of the cases provide the minimum amount of flexibility. Based on this information, the lower values of This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 𝑆𝑂𝐶෪ ௧ ௠௜௡ often leads to a higher amount of flexibility. For instance, the cases with 𝑆𝑂𝐶෪ ௧ ௠௜௡ = 0.2 ranked first and second in terms of the values of flexibility offers. Since the community’s production surplus is negative in the early hours of the next day, discharging the BESS can provide upward flexibility during these time slots. As a result, the lower values of 𝑆𝑂𝐶෪ ௧ ௠௜௡ enables the LEC to provide more upward flexibility through BESS discharging. In comparison, higher values of 𝑆𝑂𝐶෪ ௧ ௠௔௫ do not necessarily lead to a higher amount of flexibility. Case 4 is an example with a high value of 𝑆𝑂𝐶෪ ௧ ௠௔௫ while having the lowest values for the total flexibility offer. FIGURE 5. Upward flexibility offer by the LEC considering different cases Fig. 5 shows that the LEC is able to provide upward flexibility during 09:00–14:00, even in the cases with low DBU (i.e. G3). Considering Fig. 4, the production surplus is positive during 09:00–14:00, which enables the LEC to provide upward flexibility even without the help of the BESS. As Fig. 5 shows, for G1, the LEC can offer upward flexibility in most of time slots. In addition, the only difference between G2 and G3 is that G2 is able to offer additional flexibility during hour 05:00 by utilizing the BESS. FIGURE 6. Downward flexibility offer by the LEC considering different cases Fig. 6 demonstrates that the LEC of G1, G2 and G3 is able to provide downward flexibility during time slots when EVs (see TABLE ) are being charged in all of the considered cases. As mentioned before, the only resources for the provision of downward flexibility are regarded to be EVs and the BESS. Since in G3 the LEC utilizes less than 50% of its BESS’s capacity, the downward flexibility of this case is mostly provided by charging the EVs. However, G1, which deploys greater BESS capacity, is able to offer downward flexibility in most of the time slots. Although the downward flexibility offered by G2 is approximately similar to the amount offered by G3, the community of G2 utilized its BESS at 07:00 to provide more downward flexibility. Note that EVs are plugged in after 08:00, meaning that the downward flexibility offered at 07:00 was provided solely from the BESS. 2) REAL-TIME SCHEDULING In real-time, the BSP specifies the amount of flexibility that should be provided by the LEC. In order to obtain the assigned amount of flexibility, we extracted information on the type of flexibility activation during the specific day (i.e. July 7, 2019) from the Finnish TSO’s open data [8]. Subsequently, based on these data, the BSP accepts either the upward or the downward flexibility. In a few time slots there exist no need for mFRR deployment, which implies that no flexibility offers are accepted. Note that it is assumed that the total amount of offered flexible capacity by the LEC, which are compliant with the flexibility needs, were fully accepted and assigned by the BSP. FIGURE 7. Assigned upward flexibility for different cases FIGURE 8. Activated upward flexibility for different cases Fig. 7 and Fig. 8 illustrate the respective assigned and activated values of upward flexibility required to be provided by the LEC. Fig. 9 and Fig. 10 depict the respective assigned and activated values of downward flexibility required to be provided by the community. The activated amount of flexibility is also deployed based on the data of activated balancing power obtained for July 7, 2019 [8], and depicted in Fig. 7 to Fig. 10. The amount of assigned and activated flexibility is calculated for the three groups considered in the previous section, G1, G2 and G3. This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 The flexibility prices for provision of upward and downward balancing services are considered to be known in real-time and are presented in Fig. 11 [8]. These prices are extracted from the information on the prices of balancing energy markets on July 7, 2019, which are determined by the Finnish TSO, Fingrid. Moreover, the dynamic prices of trading energy with the grid is also shown in Fig. 11, based on one of the Finnish DSOs’ open data [39]. As can be seen in the figure, the price of selling upward flexibility are always equal to or greater than the price of selling power to the grid. Additionally, the price of buying downward flexibility is always equal to or lower than the price of buying power from the grid. FIGURE 9. Assigned downward flexibility for different cases FIGURE 10. Activated downward flexibility for different cases The optimization problem introduced through (20)–(35) has been solved for the proposed LEC. A linearization technique (see APPENDIX) is exploited to handle the non-linearity caused by (25) and (26), with the purpose of obtaining a mixed-integer linear programming (MILP) formulation. The input data on the SOC of the EVs and the BESS were considered to be updated based on the actual activated reserve, and the results of 24 hours are obtained. Fig. 12 illustrates the hourly real-time profits of the community for one day, considering four different cases. These cases consist of three groups introduced in the previous section (i.e. G1, G2 and G3), which consider the LEC adopting different BESS control parameters in its day-ahead schedule, along with a case that suggests the LEC’s operation with no contribution to reserve provision (i.e. the LEC trades only with the upstream grid and does not tend to participate in reserve provision). Fig. 13 denotes the total net-costs of the LEC on the considered day. The share of daily income and costs stemming from different resources are also illustrated in Fig. 14. FIGURE 11. Prices for trading energy and flexibility, July 7, 2019 [8] By comparing Fig. 12 with Fig. 4, it can be concluded that the profit of the LEC leads to positive values in time slots when the LEC has production surplus. However, in the rest of the time slots, the profits mostly exhibit negative values, meaning that the community is required to purchase power either from the upstream grid or by providing downward flexibility services in order to meet its demand. After solving the optimization problem for different cases, it was concluded that the LEC of G1 and G2 was not able to provide the assigned reserve during some time slots. Consequently, in these cases, the LEC is assumed to buy energy from the upstream network (through the DSO or retailer) so as to fulfil its assigned flexibility. Hence, in a few hours of the day, the profit curves related to G1 and G2 experience a considerable decrease. By comparing G1 with G3, it could be realized that G1’s curve fluctuates more than G3’s. Although in a limited number of hours G1’s curve experiences higher profits (e.g. during time slots 02:45 and 11:15 to 11:45), it incurs more costs early in the morning (e.g. during time slots 02:00–02:15, 03:15, 05:15 and 15:00–15:45). FIGURE 12. Hourly profits of the LEC for different cases Fig. 13 indicates the correlation between the day-ahead selection of control parameters and the real-time net-cost of the LEC. It shows that the total net-cost of G1 is higher than This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 that of G3 for the studied day. The same situation with a lower degree happens for G2, resulting in a higher total net-cost compared to G3 (see Fig. 13). In comparison, the case in which the LEC does not participate in reserve provision leads to the total cost which stands in the second rank, compared to the three studied cases. This means that the total net-cost of the case in which the LEC decides not to participate in reserve provision is higher than the net-costs of G3 and G2, but lower than that of G1. By comparing cases with different control parameters, i.e. G1, G2 and G3, it can be concluded that it is more profitable when the LEC deploys less BESS capacity in its day-ahead flexibility offer. In other words, according to fig. 13, the LEC made more profits when it chose a high value for 𝑆𝑂𝐶෪ ௧ ௠௜௡ and a low value for 𝑆𝑂𝐶෪ ௧ ௠௔௫ . FIGURE 13. Total daily net-cost of the LEC considering different cases Fig. 14 illustrates the sources of costs and incomes of the LEC, taking into account different cases. According to the community’s day-ahead schedule, the income obtained from trading TSO-level flexibility is greater for G1, followed by G2 and G3 respectively, in terms of obtaining reserve-related income. The LEC is not able to benefit from flexibility provision if it does not claim its flexibility capacity in day- ahead, as stated in the bar chart of this case in Fig. 14. FIGURE 14. The LEC’s monetary turnover in a single day considering different cases However, the costs of real-time energy trading for G1 and G2 increase, as they need to compensate for hours during which they were not able to provide the assigned flexibility. In addition, in these cases the LEC sold a considerable amount of its production capacities through their day-ahead schedules in order to provide TSO-level flexibility. As a consequence, the community is not able to sell this part of their capacity to the upstream network, which leads to a decline in energy-trading income. Moreover, Fig. 14 implies that the higher participation of the LEC in reserve provision leads to more utilization of BESS capacity in real-time. Therefore, the operating costs of the BESS increase if the LEC provides more flexible capacity. FIGURE 15. The power traded between the LEC and the upstream grid FIGURE 16. SOC variation of the BESS considering different cases Fig. 15 visualizes the power sold/purchased to/from the upstream network. Positive values are related to the input power while negative values show the output power exported from the community. It expresses that the LEC of G1, G2 and G3 sells a negligible amount of its capacity to its upstream network, whereas in the case with no reserve provision, the community is able to sell all of its production surplus to the upstream grid. This is due to the fact that in G1, G2 and G3, the LEC sold most of its production capacities for reserve provision. When it comes to the amount of energy imported to the community, a short-term fluctuation for the LEC of G1 can be seen, owing to fulfilling its assigned upward flexibility offers. These fluctuations occur in few time slots during the This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 early morning as well as from 21:00 to 23:00. Similar fluctuations could be seen for the LEC of G2 in some quarters during 22:00. The SOC variation of the BESS for different cases is illustrated in Fig. 16. This figure explains that the participation of the BESS in reserve provision leads to greater utilization of the BESS. Comparing the SOC of the BESS for the LEC of G1 and G2 with that of G3 points out that the higher participation in reserve provision results in more variation in the SOC and thus more deployment of BESS capacity. In other words, the LEC of G1utilized a higher amount of its BESS capacities and therefore experienced more fluctuations in terms of its BESS’ SOC. In comparison, these fluctuations decrease for the LEC of G2 and G3. In this manner, the case with no reserve participation deploys the BESS’s capacity only from 22:00 to 24:00. In the “No reserve participation” case, the LEC does not take advantage of the charging capacity of the BESS at all. Note that the minimum allowed values of the BESS’s SOC and of its initial SOC were assumed to be 0.2 and 0.5, respectively. Moreover, Fig. 16 shows that the LEC utilizes the discharging capacity more frequently than the charging capacity. Finally, the number of EVs being charged in different time slots is illustrated in Fig. 17, considering the studied cases. The daily number of charging quarters for all of the EVs in the considered day (i.e. ∑ ∑ ∑ 𝑢௜,௧,௠ ா௏ ௠௧௜ ) is shown in TABLE V. This table explains how much the LEC utilized the charging capacity of EVs. The results discuss the fact that the number of charging EVs is greater in the case when the LEC does not tend to provide reserve, and it decreases for the other cases. The total number of charging EVs reaches its minimum value for G1, since it had to provide higher upward flexibility in most of the time slots, which leads to less utilization of charging EVs’ (i.e. downward flexible capacity). In this manner, LECs of G2 and G3 place in the middle rank in terms of charging their EVs. FIGURE 17. The hourly number of EVs being charged during the studied day considering different cases TABLE V. The daily total number of charging quarters for all EVs considering different cases Case Study Daily number of charging quarters G1 57 G2 66 G3 66 No reserve participation 68 V. CONCLUSION AND FUTURE WORKS This paper deals with the optimal scheduling of an LEC participating in the provision of mFRR services. The LEC is considered to have shared assets, enabling it to contribute to the reserve provision. The scheduling comprises two stages. In the first stage, the ECMC seeks to determine the offered flexibility which should be submitted to the BSP in the day- ahead stage. In this stage, control parameters are deployed so as to manage the degree of the BESS utilization for offering the flexible capacity. In the second stage, the ECMC aims to maximize the community’s real-time profit for each hour. The real-time stage also takes into account the assigned flexibility that should be provided in the following four quarters and the activated flexibility during the previous hour. The proposed scheduling method was applied to a case study, comprised of a hypothetical LEC with a PV system, a BESS, EVs and several households as residential consumers. The paper utilized the structure of Finnish balancing energy and capacity markets related to mFRR procurement for the simulation. Hence, the data regarding reserve market prices, dynamic tariffs and solar power were fully extracted from the related Finnish utilities (Finnish TSO and DSO) and markets. The results demonstrate that the control parameters chosen in the day-ahead schedule can strongly affect the real-time profitability of the LEC. It was also concluded that the cases in which the LEC utilized a low capacity of the BESS in its day-ahead schedule were more profitable compared to those cases in which the BESS capacity was highly utilized. Moreover, the cases which deploy lower capacity of the BESS were more profitable in comparison with the cases where the LEC did not participate in mFRR provision. According to the simulation results, which were based on input data extracted from the real-world reserve markets, the participation in mFRR provision can be profitable for the LEC as a distribution-network-located energy resource. Hence, participating in providing mFRR ancillary services not only helps the TSO, but also increases profits for the LEC. However, the careful utilization of the BESS in estimating the LEC’s day-ahead available flexibility is vitally important in real-time profitability and the LEC’s optimal real-time operation. Finally, this paper could be expanded in the future by analyzing the following directions: a) LECs providing other types of flexibility services such as FCR-N or FCR-D to the TSO. b) The provision of flexibility from LECs in the most recently introduced FFR market could also be considered as another important study. c) Different kinds of FERs in energy communities such as thermostatically controllable loads and thermal storages could be analyzed for flexibility provision. d) The TSO’s responsibilities related to calculating flexibility needs and clearing each flexibility market (FFR, FCR, FRRs) according to the calculated requirements. This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 APPENDIX As mentioned in the simulation section, we utilized the same approach as [37] to linearize (10), (11), (25) and (26). All of these constraints are in the form of the following equation. 𝐴 = ቄ 𝐵 if 𝐵 > 0 0 else (35) In (35), A and B are two variables. In this case, an auxiliary binary variable V is adopted and constraint (35) will be replaced with the following constraints: 𝐴 ≤ 𝑉𝑀 (36) 𝐴 ≤ 𝐵 + 𝑀(1 − 𝑉) (37) 𝐴 ≥ 𝐵 − 𝑀(1 − 𝑉) (38) 𝐴 ≥ 0 (39) Where M is a large number, which was chosen to be 10000 in our problem. In this manner, if B becomes negative, V and A equal 0. Otherwise, V is equal to 1 and A is equal to B, accordingly. REFERENCES [1] B. Mohandes, M. S. El Moursi, N. D. Hatziargyriou, and S. El Khatib, “A review of power system flexibility with high penetration of renewables,” IEEE Trans. Power Syst., 2019. [2] M. Džamarija, G. Leclercq, M. Marroquin, and M. Herman, “Modeling of Complex Systems Including Transmission, Distribution, Aggregation, Ancillary Services Markets,” in TSO-DSO Interactions and Ancillary Services in Electricity Transmission and Distribution Networks, Springer, 2020, pp. 25–59. [3] M. Khoshjahan, M. Moeini-Aghtaie, and M. Fotuhi-Firuzabad, “Developing new participation model of thermal generating units in flexible ramping market,” IET Gener. Transm. Distrib., 2019. [4] H. Gerard, E. Rivero, and J. Vanschoenwinkel, “TSO-DSO Interaction and Acquisition of Ancillary Services from Distribution,” in TSO- DSO Interactions and Ancillary Services in Electricity Transmission and Distribution Networks, Springer, 2020, pp. 7–23. [5] H. Khajeh, H. Laaksonen, S. Gazafroudi, and M. Shafie-khah, “Towards flexibility trading at TSO-DSO-customer levels: a review,” 2019. [6] G. De Zotti, S. A. Pourmousavi, H. Madsen, and N. K. Poulsen, “Ancillary services 4.0: A top-to-bottom control-based approach for solving ancillary services problems in smart grids,” Ieee Access, vol. 6, pp. 11694–11706, 2018. [7] P. Spodniak, K. Ollikka, and S. Honkapuro, “The relevance of wholesale electricity market places: the Nordic case,” 2019. [8] Fingrid Oyj, “Fingrid open data.” . [9] B. Xu, Y. Shi, D. S. Kirschen, and B. Zhang, “Optimal battery participation in frequency regulation markets,” IEEE Trans. Power Syst., vol. 33, no. 6, pp. 6715–6725, 2018. [10] R. H. Byrne, T. A. Nguyen, D. A. Copp, B. R. Chalamala, and I. Gyuk, “Energy management and optimization methods for grid energy storage systems,” IEEE Access, vol. 6, pp. 13231–13260, 2017. [11] M. Merten, C. Olk, I. Schoeneberger, and D. U. Sauer, “Bidding strategy for battery storage systems in the secondary control reserve market,” Appl. Energy, vol. 268, p. 114951, 2020. [12] E. Nasrolahpour, J. Kazempour, H. Zareipour, and W. D. Rosehart, “A bilevel model for participation of a storage system in energy and reserve markets,” IEEE Trans. Sustain. Energy, vol. 9, no. 2, pp. 582– 598, 2017. [13] H. Alharbi and K. Bhattacharya, “Participation of Pumped Hydro Storage in Energy and Performance-Based Regulation Markets,” IEEE Trans. Power Syst., 2020. [14] B. Han, S. Lu, F. Xue, and L. Jiang, “Day-ahead electric vehicle aggregator bidding strategy using stochastic programming in an uncertain reserve market,” IET Gener. Transm. Distrib., vol. 13, no. 12, pp. 2517–2525, 2019. [15] R. J. Bessa and M. A. Matos, “Optimization models for an EV aggregator selling secondary reserve in the electricity market,” Electr. Power Syst. Res., vol. 106, pp. 36–50, 2014. [16] P. González, J. Villar, C. A. Díaz, and F. A. Campos, “Joint energy and reserve markets: Current implementations and modeling trends,” Electr. Power Syst. Res., vol. 109, pp. 101–111, 2014. [17] Q. Wang, C. Zhang, Y. Ding, G. Xydis, J. Wang, and J. Østergaard, “Review of real-time electricity markets for integrating distributed energy resources and demand response,” Appl. Energy, vol. 138, pp. 695–706, 2015. [18] P. H. Divshali and C. Evens, “Stochastic bidding strategy for electrical vehicle charging stations to participate in frequency containment reserves markets,” IET Gener. Transm. Distrib., vol. 14, no. 13, pp. 2566–2572, 2020. [19] J. Iria, F. Soares, and M. Matos, “Optimal bidding strategy for an aggregator of prosumers in energy and secondary reserve markets,” Appl. Energy, vol. 238, pp. 1361–1372, 2019. [20] S. R. Dabbagh and M. K. Sheikh-El-Eslami, “Risk assessment of virtual power plants offering in energy and reserve markets,” IEEE Trans. Power Syst., vol. 31, no. 5, pp. 3572–3582, 2015. [21] H. Nezamabadi and M. S. Nazar, “Arbitrage strategy of virtual power plants in energy, spinning reserve and reactive power markets,” IET Gener. Transm. Distrib., vol. 10, no. 3, pp. 750–763, 2016. [22] E. Mashhour and S. M. Moghaddas-Tafreshi, “Bidding strategy of virtual power plant for participating in energy and spinning reserve markets—Part I: Problem formulation,” IEEE Trans. Power Syst., vol. 26, no. 2, pp. 949–956, 2010. [23] M. Mohammadnejad, A. Abdollahi, and M. Rashidinejad, “Possibilistic-probabilistic self-scheduling of PEVAggregator for participation in spinning reserve market considering uncertain DRPs,” Energy, vol. 196, p. 117108, 2020. [24] C. Giovanelli, O. Kilkki, S. Sierla, I. Seilonen, and V. Vyatkin, “Task allocation algorithm for energy resources providing frequency containment reserves,” IEEE Trans. Ind. Informatics, vol. 15, no. 2, pp. 677–688, 2018. [25] T. K. Chau, S. S. Yu, T. Fernando, and H. H.-C. Iu, “Demand-side regulation provision from industrial loads integrated with solar PV panels and energy storage system for ancillary services,” IEEE Trans. Ind. Informatics, vol. 14, no. 11, pp. 5038–5049, 2017. [26] J. Wang et al., “Optimal bidding strategy for microgrids in joint energy and ancillary service markets considering flexible ramping products,” Appl. Energy, vol. 205, pp. 294–303, 2017. [27] S. Lilla, C. Orozco, A. Borghetti, F. Napolitano, and F. Tossani, “Day- ahead scheduling of a local energy community: An alternating direction method of multipliers approach,” IEEE Trans. Power Syst., vol. 35, no. 2, pp. 1132–1142, 2019. [28] P. Van Aubel, M. Colesky, J.-H. Hoepman, E. Poll, and C. Montes Portela, “Privacy by design for local energy communities,” 2018. [29] A. R. Servent, The European Parliament. Macmillan International Higher Education, 2017. [30] Natascha van Bommel, “Energy communities: an exploration into their rhetoric framings within the European Policy Context,” Eindhoven University of Technology, 2019. [31] Fingrid Oyj, “Terms and conditions for providers of Manual Frequency Restoration reserves (mFRR),” 2020. [32] Nordpool, “Nordpool market data.” . [33] Z. Zhang, R. Li, and F. Li, “A Novel Peer-to-Peer Local Electricity Market for Joint Trading of Energy and Uncertainty,” IEEE Trans. Smart Grid, 2019. [34] M. Hemmati, B. Mohammadi-Ivatloo, M. Abapour, and A. Anvari- Moghaddam, “Optimal Chance-Constrained Scheduling of Reconfigurable Microgrids Considering Islanding Operation Constraints,” IEEE Syst. J., 2020. [35] T. A. Nguyen and M. L. Crow, “Stochastic optimization of renewable- based microgrid operation incorporating battery operating cost,” IEEE Trans. Power Syst., vol. 31, no. 3, pp. 2289–2296, 2015. [36] H. Khajeh, A. A. Foroud, and H. Firoozi, “Robust bidding strategies and scheduling of a price-maker microgrid aggregator participating in a pool-based electricity market,” IET Gener. Transm. Distrib., vol. 13, no. 4, pp. 468–477, 2018. This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/. This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/ACCESS.2020.3027710, IEEE Access VOLUME XX, 2017 9 [37] IEEE spectrum, “How Inexpensive Must Energy Storage Be for Utilities to Switch to 100 Percent Renewables?” . [38] M. Shabanzadeh, M.-K. Sheikh-El-Eslami, and M.-R. Haghifam, “Risk-based medium-term trading strategy for a virtual power plant with first-order stochastic dominance constraints,” IET Gener. Transm. Distrib., vol. 11, no. 2, pp. 520–529, 2017. [39] Vaasan Sahko, “Prices for electricity products.”. HOOMAN FIROOZI received his M.Sc. (Tech.) degree in electrical engineering (power systems) from Ferdowsi University of Mashhad, Mashhad, Iran, in 2016. Currently, he is working as a project researcher at the University of Vaasa, Vaasa, Finland. His areas of interest include the application of optimization techniques (classic and metaheuristic) in the operation and planning of smart energy systems, distributed and flexible energy resources integration, balancing services and flexibility markets, energy communities and microgrids. HOSNA KHAJEH received her M.Sc. (Tech.) degree in electrical engineering (power systems) from Semnan University, Semnan, Iran, in 2016. She is currently working as a project researcher and pursuing her Ph.D. studies at the University of Vaasa, Vaasa, Finland. Her field of interests include future electricity market concepts (such as flexibility markets and local peer-to-peer markets), smart grid and microgrid scheduling and renewable energy integration. HANNU LAAKSONEN received his M.Sc. (Tech.) degree 2004 in electrical power engineering from the Tampere University of Technology, Tampere, Finland, in 2004 and his Ph.D. (Tech.) degree in electrical engineering from the University of Vaasa, Vaasa, Finland, in 2011. His employment experience includes working as a research scientist at the VTT Technical Research Centre of Finland and at the University of Vaasa. He has previously worked as a principal engineer at ABB Ltd. in Vaasa. He is currently a professor of electrical engineering at the University of Vaasa. He is also the manager of the Smart Energy Master’s Program. His field of interests are the protection of low-inertia power systems (including microgrids), active management of distributed and flexible energy resources in future smart energy systems as well as future-proof technology and market concepts for smart grids.