Battery Storage Participation in Reactive and Proactive Distribution-Level Flexibility Markets

Modern power systems are experiencing a paradigm shift toward distributed energy resources (DERs) and an accelerated penetration of the renewable energy sources (RES). Intermittent and distributed RES pose serious challenges to the system operators in terms of the increased flexibility requirements. Besides the technical flexibility, achieved through, e.g. storage devices, the market flexibility is also important as it enables rewarding the flexibility providers at an appropriate time-scale. Distribution-level flexibility market (DLFM) is considered as one of the viable solutions to successfully integrate high shares of RES and promote an active role of electricity consumers. This paper defines and analyzes two DLFM setups where a distributed flexibility source, i.e. battery energy storage, can bid in addition to the existing markets (day-ahead, intraday and balancing). The main difference between the observed DLFM setups is their clearing time. One clears before the day-ahead market, while the other one in between the day-ahead and the intraday markets. Uncertainty in the intraday market is addressed using robust optimization, while stochastic optimization deals with the DLFMs and the day-ahead market. This results in a four-stage model, which is reduced to a three-stage model because the balancing market follows directly from the previous market position realizations. In the presented case study, we analyze how different market clearing sequences affect both the player providing flexibility and the market operator procuring it.


I. INTRODUCTION A. MOTIVATION
Excluding the distribution and transmission system operators as textbook examples of natural monopolies, modern electrical power systems lean towards free market principles. Hence, they are open for participation to any interested party that meets certain technical and economical requirements [1]. Aggregators of distributed energy resources' (DERs) [2] are profit-oriented players who may make contractual arrangements with different parties. Consequently, their portfolios are composed of a wide variety of services and technologies (demand response, renewable energy resources -RES, battery storage, etc.) and they may bid in different electricity markets: day-ahead market (DAM), intraday market (IDM), balancing market (BM), etc. It is the diversity of technologies in their portfolio and their availability to participate in various markets that drives the profit amplitudes between the optimal and sub-optimal solutions. More specifically, each The associate editor coordinating the review of this manuscript and approving it for publication was Chenghong Gu . technology has its own technical peculiarities, whereas the markets have specific rules. Hence, such complementarity may result in high profits, but also in high costs in case of flawed modeling and poor predictions. Competitive markets do not tolerate sub-optimal strategies, so it is in the players' best interest to ensure optimal market performance to prevail their rivals. Furthermore, the complexity of the problem at hand increases with the addition of new markets. Academic, industrial and political efforts are all currently focused on accelerating the shift toward green technologies (i.e. fast penetration of RES) and implementation of a modern power market design with an emphasis on active consumers (i.e. prosumers), decentralized locations of energy resources and flexibility [3].
Considering the intermittent nature of RES, an important question is how to accommodate high shares of RES in the total energy mix while ensuring safe and reliable power supply at all times. Many research projects across the globe deal with these problems. One of them is HORIZON2020 project FLEXGRID [4], which proposes a novel distribution-level flexibility market (DLFM) as a solution to facilitate high RES penetration and an active role of consumers. Existence of the DLFM creates, on the one hand, opportunities for the Transmission System Operator (TSO) and the Distribution System Operator (DSO) to procure flexibility services and avoid network problems. On the other hand, the DLFM presents an opportunity for profit-oriented entities, e.g., aggregators, to generate profit by offering their services in a new market. As aggregators already take part in the existing markets, it is important for them to generate a schedule that yields higher overall profit. Hence, based on the different DLFM setups, flexibility providers will have to pay even more attention to their scheduling to minimize deviations from their market position, which may result in the balancing market penalties, and reduce their inability to provide a contracted service. Such failure may result in disqualification from certain markets.
We find it interesting and important to examine the consequences of different market setups and simplicity of integration into the current market design. The more efficient the newly proposed DLFM is, the faster and higher RES integration may be achieved. Therefore, this paper examines the behaviour of a profit-oriented market player that bids not only in the conventional markets, but also in the newly proposed DLFM. Moreover, an analysis of the aggregator's behaviour under different market setups (sequence of the market clearing), may identify the most promising approach where both, the entity that procures the flexibility (i.e. DSO), and the entity that offers flexiblity services will indeed benefit from such market setup.
Specifics of different DLFM setups are examined focusing on how they fit the existing market structure. In that manner, the DAM, the IDM, the BM and two versions of the DLFM are modeled. The developed optimization problem finds a schedule that brings the highest utility to the flexibility provider, in our case a battery storage owner, considering the uncertainties, constraints and characteristics of each individual market and the market structure in general. Also, pros and cons of the two DLFM setups are analyzed and explained with recommendations for further research.

B. LITERATURE REVIEW
The operational expenditures (OPEX) minimization is a scheduling optimization problem. Depending on the number and type of the observed markets, this problem may become difficult to formulate and solve. We divide this literature review into two parts. First, we examine state-of-the-art battery storage scheduling and bidding models, as these models are a basis for the battery storage bidding model developed in this paper. Second, we investigate the literature on local flexibility markets, as this is the setting for our model. Based on the reviewed literature, we articulate the contribution of our work in subsection I-C.

1) SCHEDULING AND BIDDING
Battery storage units may be utilized in various manners, considering both the network and market applications. Hence, the academia and the industry analyze storage units' benefits both at the transmission and the distribution level. Some basic models that consider energy arbitrage only are presented in [16] and [11]. The former paper proposes an optimization strategy to coordinate the operation of large, price-maker, and geographically dispersed battery storage systems in a nodal transmission-constrained energy market. The latter one models a price-maker battery storage participating in the DAM. The authors acknowledge that the size and location of the battery storage plays an important role in its profit possibilities. Furthermore, they argue that participating only in the DAM does not generate sufficient profit for this business model to be attractive. Therefore, it makes sense to examine additional revenues and analyze battery storage participation in other markets. In this sense, the authors in [15], besides the DAM, observe the real-time market in California. Furthermore, Akhavan-Hejazi et al. [17] developed an optimal price-taker bidding algorithm to offer both energy and reserve in the DAM and IDM when intermittent energy resources cause significant price fluctuations. [10] considers the DAM, annual capacity reservation and an annual market for RES certificates. Conditional Value-at-Risk is used to model risk-averse behaviour. The results indicate that in the proposed price-maker model the capacity markets are more beneficial in a market where players participate in a risk-averse manner. Pandzic et al. [7] proposed a novel short-term scheduling of the battery storage unit and modeled its participation in the DAM, the day-ahead reserve capacity and the activation market as a price maker, putting special emphasis on the accurate battery charging model. Also, bilevel optimization is proposed in a similar manner in [8], where the authors model strategic behaviour of a price-making battery storage. They consider energy, reserve and real-time balancing market while ensuring the real-time availability of the operating reserves by including a set of worst-case reserve activation constraints. [9] concludes our survey of models for price-making battery storage participating in the DAM, the reserve capacity and balancing (or real-time) markets. Their data-driven scheduling approach enables increased profits using more aggressive strategies, but still maintaining high reliability. VOLUME 9, 2021 While all of the examined papers focus on the transmission level, there are papers that model distribution-level battery storage bidding strategies, [12]- [14]. In [12], a distributed storage's profit is maximized by providing: a) at the distribution level: distribution network congestion management including network constraints and b) at the transmission level: energy price arbitrage, various reserve and frequency regulation services through both active and reactive power control. The authors claim that their model is able to promote efficient integration of new distributed battery storage projects while ensuring appropriate financial compensations for the investors. Megel et al. [13] use a model predictive control approach to demonstrate how a set of distributed battery storage units can simultaneously provide local services individually and system services in aggregate. They argue that a proper multitasking approach may double the overall storage profits, even more if their local services are related to the overloading and are requested rarely. The paper focuses on a price-taking model in capacity reservation, capacity activation and local markets. A price-taking model for capacity reservation and local market is developed in [14]. The authors propose a two-phase optimization problem, where the first phase deals with the battery power and energy budget allocation to different services, while the second phase controls the set-points for the deployment of such services.
A summary of the covered topics for each of the reviewed papers is given in Table 1, indicating for each of the considered markets whether the ES is a price-taker (T) or a price-maker (M). A general observation is that the distribution-level local markets are still largely neglected in the literature. Thus, the goal of this paper is to make a step toward the integration of local flexibility markets in the existing power market structures.

2) LOCAL FLEXIBILITY MARKETS
The second part of the literature survey considers academic efforts in modeling the local flexibility markets. There is already a number of papers dealing with this topic, and review papers [18]- [20] support this claim. Flexibility markets are considered as an efficient tool to deal with congestion issues and voltage violations [21], [22], network expansion problems [23], intermittency and uncertainty of renewable generation and integration of distributed energy resources [24]. In [21], local flexibility market takes place after the DAM clearing and considers the aggregator as the main flexibility market player, alongside DSO as the interested party and market operator. Aggregator as a new market agent is also introduced in [22], where the authors present a framework for local flexibility market in a general manner with an emphasis on enabling the participants to compete for selling or buying flexibility. The authors in [23] approach this problem in a slightly different manner, providing a methodology for calculating the flexibility needed to defer network expansion and similar capital investments with economically more reasonable solutions. Morstyn et al. [25] investigate how a decentralized flexibility market may help the DSO by motivating small energy resources (e.g. electric vehicles, home batteries) to provide flexibility via an aggregator. Perks of such model are autonomy and privacy, while the downside is that this approach does not account for losses, reactive power flows or voltage limits. Torbaghan et al. [26] introduce flexibility market in similar manner as [25], but using a bi-level model with the upper level goal to minimize the DSO's flexibility procurement cost (DSO's bid price), while the lower level denotes the flexibility DAM and IDM clearing (flexibility quantities). To avoid causing additional congestion, flexibility markets are cleared before the wholesale markets, but should that fail the authors have incorporated mechanisms for the DSO to voluntarily and compulsory manage the consumption profile.
Some papers tackle optimal participation both in the existing wholesale market structures and novel local markets [27]- [29]. In [27], a two-stage co-optimization models participation in the DAM (first stage) and the real-time flexibility market (second stage). On the other hand, [28] presents an optimization model for home energy management systems from an aggregator's standpoint. It also considers the DAM and flexibility markets. The objective is to minimize the day-ahead operation costs for the aggregator while complying with energy commitments in the DAM and local flexibility requests. Finally, [29] observes an end-user acting individually in the local market and in the wholesale market through an aggregator. The proposed algorithm increased the end-user's profits by participating in the local market.
On top of the academic literature, it is important to mention the Smart Grid Architecture Model (SGAM), which was developed by standardization agencies CEN, CENELEC and ETSI to provide a common reference framework for smart grids [30]. Many papers and research projects follow the SGAM framework [31]. For instance Pavlovic et al. [32] propose an SGAM business layer for a local flexibility market. Also, here we list here two HORIZON 2020 projects that follow the SGAM architecture: i) SmartNet [33] -it deals with coordination between the grid operators at the national and the local level (respectively the TSO and DSO) and the exchange of information for monitoring and for acquisition of ancillary services from subjects located in the distribution segment (flexible load and distributed generation), ii) TDX-Assist [34] -aiming at coordination of transmission and distribution data exchanges for renewables integration in the European marketplace through advanced, scalable and secure ICT systems and tools. Considering that our paper is a result of the work conducted within the FLEXGRID project [4] funded by the European Commission, DLFM is of great interest within the future European market design.

C. PAPER CONTRIBUTION AND STRUCTURE
Analyzing the findings of the conducted literature survey, the conclusion is that there are many papers dealing with the optimal bidding and scheduling problems of flexibility assets, mostly focused on energy storage. Similarly, design of the potential distribution-level flexibility markets is in the phase of research expansion. It is fairly clear that the research community has noticed the need for flexibility markets as a solution for RES integration. The surveyed articles lack the uncertainty consideration and a rigorous market-by-market representation and coordination within the bidding model. Also, it has not been examined how may various flexibility market proposals influence the existing market structures. Another important research gap is the connection of the existing market structures with the potential local flexibility markets including optimal bidding and scheduling strategies for participating agents. In this manner, contribution of the paper consists of the following: • Introduction of a market design that incorporates a local flexibility market compatible with the existing structures.
• The proposed battery storage bidding models consider the market uncertainty. The IDM uncertainty, due to its continuous trading nature, is addressed using robust optimization, while stochastic optimization is used for DAM, BM and DLFM, which are auction-based markets.
• Two types of DLFM are proposed and examined, the Proactive DLFM (P-DLFM) clears before the DAM, and the Reactive-DLFM (R-DLFM) after the DAM. The rest of the paper is structured as follows. Section II formulates the mathematical model both for the R-and P-DLFM market setups that are explained in subsection II-A. Section III presents a case study based on the Croatian electricity market and elaborates on the results. Finally, section IV brings the conclusion and final remarks.

II. MATHEMATICAL MODEL
The developed model includes the DAM, the IDM, the BM and the distribution level flexibility market -DLFM. Two versions of the DLFM are modeled. The first one is referred to as Reactive-DLFM (R-DLFM) and it clears after the DAM, while the second one, Proactive DLFM (P-DLFM), precedes the DAM clearing.
A. MARKET SETUP Figure 1 illustrates the chronological relationship between the existing market structure (orange arrows), namely the DAM, the IDM and the BM, and two newly proposed DLFM (yellow and blue arrows). The three existing markets are at the transmission level, while the DLFM is at the distribution level, as thoroughly described in [35]. The main difference between the P-DLFM and the R-DLFM is their clearing time. The P-DLFM clears before the DAM, while the R-DLFM clears between the DAM and the IDM. Both DLFMs are distribution-level markets and operated by the flexibility market operator. Only one of the two proposed DLFMs can operate as they would collide if both existed at the same geographical location. To analyze their characteristics and repercussions on the battery storage unit operations, we develop two independent battery storage bidding models based on the chronological location of the DLFM. The first one is the reactive DLFM (R-DLFM), which clears after the DAM, and the second one is the proactive DLFM (P-DLFM), which clears before the DAM.

B. R-DLFM
In the R-DLFM market setup, the proposed flexibility market follows the DAM. The sequence continues with the IDM and, finally, the BM as a penalization instrument for the deviations from the market schedule. Accordingly, the level of available information differs from one market to another. The DAM schedule needs to be decided without knowing the prices in any of the markets, while the bidding strategy in the R-DLFM is determined with the DAM cleared price and quantity information. Battery storage operation in the IDM is planned knowing both the DAM and the R-DLFM prices, whereas trading in the BM is merely a consequence of the actions in the previous markets. The battery storage unit operator's optimal bidding in the DAM, R-DLFM, IDM and BM markets is formulated as follows: soe s,k,24 ≥ SOE s,k,0 , ∀s, k Objective function (1) follows the chronological order of the markets and information availability, taking into account the price uncertainties. Set of variables is ζ x ID s,k,t , x s,k,t , g s,k,t , c s,k,t , d s,k,t , soe s,k,t , soe t,i,s,k , soe s,k,t . The first term in (1) represents the DAM charging (ch DA t ) and discharging (dis DA t ) schedule that needs to be decided before knowing the DAM prices. Probabilities π s weigh the DAM price scenarios λ DA s,t to obtain the expected DAM price. The second row reflects the flexibility market, whose prices depend on the realized DAM price clearing scenario s, deciding the up and down flexibility (f ↑ s,t , f ↓ s,t ). The third row models the IDM, which clears after the DAM and the R-DLFM. Due to the nature of the IDM (it is not an auction based, but a continuous pay-as-bid market), instead of relying to the stochastic optimization, we employ the robust optimization, which reflects the confidence in the IDM bidding actions. Since the IDM is pay-as-bid with continuous trading, there is no single market clearing IDM price. In other words, the traded price differs in time up to the cut-off time, usually 15 or 30 minutes before the delivery time. Because of this, we find scenarios that relate IDM prices throughout all hours inappropriate and utilize robust optimization, which models the skillfulness (and luck) of the battery storage operator. In objective function (1) the fifth and the sixth rows represent the robust sub-problem which is then transformed to its dual form, converting the inner problem to the minimization problem. The inner minimization problem can then be omitted as the outer maximization of the objective function and inner negative minimization have the same optimization direction. In a nutshell, robust optimization [36] tries to inflict as much damage as possible, meaning that for an average IDM price from the third term λ IDavg s,k,t , the robust optimization adds or subtracts value δλ IDavg s,k,t in direction that it worse for the overall objective function. This means that if a battery storage is buying energy at a specific time period in the IDM, the price would be higher than average, and if it is selling the energy, the price would be lower. Parameter is the budget of uncertainty that determines how many of the total observed time units will be affected by the robust optimization. If, out of 24 observed time periods, equals 7, only seven worst possible time periods will be affected. On the other hand, setting to 0 creates an optimistic case where no robust optimization is considered, but only the average prices, which is equivalent to the deterministic approach. Binary variable b s,k,t determines in which of the observed time periods the robust optimization will be active. Sum of all b s,k,t must be lower or equal to the budget of uncertainty ( ). Lastly, the fourth row in objective function (1) represents leveling the market positions in the BM. As the realization of actions in this market is considered as a consequence of the previous actions (i.e. deviations from the schedule), the BM is not considered as a separate stage, thus the model complexity is somewhat relaxed. Figure 2 illustrates the above-described three-stage market setup considering chronological order of the market clearing times and scenario branching. Please note that the IDM prices are generated as a robust uncertainty set, so for each scenario they may be in the range < λ ID avg s,k,t − δλ ID s,k,t , λ ID avg s,k,t + δλ ID s,k,t > and the BM is a consequence rather than a separate stage. Description of the variables and parameters used in the model is available in Table 2. For easier understanding, the parameter names in the model are in regular font, while the variable names are in italic. Constraint (2) denotes the maximum upward flexibility needed in each scenario and hour, while (3) does the same but for the downward flexibility. The DAM battery storage discharging and charging are limited by the respective maximum discharging and charging powers in (4) and (5), considering binary variable x ID t that forbids simultaneous charging and discharging. In the same manner, charging and discharging process in the IDM is modeled by constraints (6) and (7). The available flexibility power capacity, depending on the activities in the DAM and IDM, is constrained in (8) for the upward direction, and in (9) for the downward direction. Purpose of the flexibility constraints is to restrict flexibility in each direction to the physically available capacities. It takes into consideration the maximum charging/discharging power and activities planned in other markets. For example, if down flexibility is needed and discharging activities in the DAM and IDM are planned, the battery storage may provide down reserve capacity that exceeds its power rating as a portion of the down reserve is provided by simply reducing the planned discharging quantity in the DAM and IDM, and, on top of that, the battery storage can start charging up to its full power capacity. Equation (10) calculates the battery's net charging/discharging activity considering all markets where it participates, including the deviations at the balancing stage. Constraint (11) connects the net battery activity with its physical charging and discharging processes. Variable c s,k,t in constraint (12) limits the battery's overall charging activity to its rated power, while constraint (13) does the same for the discharging variable d s,k,t . Equation (14) models the battery's state of energy (soe) during the observed period depending on actions in all the markets. State of energy is constrained with the lower and the upper bound in (15). Constraint (16) ensures that state of energy at the end of the observed period is not below the state of energy at the beginning of the observed period. Constraints (17)-(20) model the battery charging capacity acknowledging the fact that the battery charging ability reduces as its state of energy increases due to entering the constant-voltage phase of the charging process. More information on this process and the model is available in [37]. Variable δsoe t,s denotes the maximum amount of energy that can be charged into the battery in a single time step depending on its state of energy. This dependence is obtained from measuring the battery charging characteristic in a laboratory. Since this characteristic is nonlinear, it is approximated by a piece-wise linear function that results with fitting parameters R i and F i . In that manner, state of energy is decomposed into I − 1 segments, where I stands for the number of breakpoints of the piece-wise function (constraint (17)). Constraint (18) limits the energy of each linear segment, while (19) determines the maximum energy charging ability of the respective battery at each time period. Finally, (20) is the maximum charging power constraint.

C. P-DLFM
The objective function and the associated constraints in the P-DLFM model share the same methodology and form as the R-DLFM. The main difference is that, in contrast to the R-DLFM setup described in the previous subsection, in the P-DLFM market setup the flexibility market precedes the DAM. Although each market is modeled following the same principles as in the R-DLFM market setup, the chronological order changes. To present the P-DLFM in concise but understandable manner, Table 2 lists all variables and parameters used in both market setups. For the sake of clarity, indices for all variables and parameters are listed in the table chronologically. For instance, although variables with sets of indices s, k, t and k, s, t are identical in mathematical sense, VOLUME 9, 2021 we explicitly follow the chronological order to emphasize the order of market clearings. Moreover, the objective function (21) is explicitly written to emphasize the differences.
By comparing the R-DLFM setup cost function (1) and the P-DLFM cost function (21), there are two major differences: i) Information availability for the DAM and the x-DLFM differs, and ii) probability coefficients differ. The DAM is in the starting point of the R-DLFM stochastic tree, hence the DAM price probabilities include only the first branching π s , while the R-DLFM price is dependent on the first and second branching. In the P-DLFM setup, the situation is opposite and P-DLFM is at the starting point, hence the flexibility prices have probabilities π k , while the DAM prices depend on two levels of branching, represented by π k,s . Figure 3 depicts the chronological market clearing times in the P-DLFM setup. By comparing figures 2 and 3 it is easy to notice how different information availability affects the potential market actions. For instance, in the P-DLFM setup, the flexibility up and down variables are optimized without any price information and they fit all future possible scenario realizations, while in the R-DLFM case the flexibility up and down variables are optimized after the DAM clearing. Thus, for each realization of the DAM price scenario, different values of flexibility variables are calculated. The IDM and BM are in fact the same in both market setups regarding the availability of information because the DAM and flexibility market prices are always known prior to the IDM and BM actions. For the sake of brevity, we assume that figures 2 and 3 alongside constraints listed in the section II-B and table 2 generate enough information so the reader may understand also the P-DLFM formulation. The main and only difference lies in the temporal dependency between the consequent market clearing times. The differences between two setups are analyzed in a more detailed manner in the following case study section.

III. CASE STUDY A. GENERAL SETUP AND INPUT DATA
The Republic of Croatia was chosen for the case study for a number of reasons. First, as Croatia heavily relies on tourism (especially coastal parts), the number of people staying on islands increases by more than a factor of two comparing the winter and summer season [38]. This results in considerable differences in power demand (both because of the number of inhabitants and the weather conditions) and different network capacity requirements. Considering the business-as-usual, without some type of flexibility market, the local distribution system operator is forced to oversize the network capacity with respect to the winter needs, so the power demand during the peak summer hours can be met. Second, Croatia was chosen because of availability of the DAM, IDM and BM prices. However, the DLFM does not yet exist in Croatia, so the prices were manually generated. The DAM and IDM price from the Croatian Power Exchange (CROPEX) [39] are used, while the BM prices are based on the current regulations in Croatia [40] and they were fetched from the ENTSO-E Transparency Platform [41].
The same market data and battery characteristics are used for both the R-DLFM and P-DLFM setups. Table 3 summarizes the input prices for the DAM, IDM, BM and DLFM. The DAM, BM and DLFM use two price scenarios each. Although the model is computationally highly tractable, we opt for a low number of scenarios to better illustrate the mechanics of the model and better illustrate the results. The likelihood of occurrence of each scenario at the first level of branching is the same, i.e. in the R-DLFM market setup each DAM price scenarios has 50% probability, while in the P-DLFM case the same principle is valid but for the P-DLFM prices, as P-DLFM is the chronologically the first market to be cleared. In the second stage, further scenarios do not have the same probabilities. The price scenarios closer to the prices from the previous stage have 80% probability, while the other one scenario has 20%. The third market in chronological order is the IDM, which is not modeled via scenarios, but using an uncertainty range, i.e. all prices in between the upper one and the lower one can occur. The occurrence depends on the preset uncertainty budget. In the final stage, the BM prices are a direct consequence of the realized DAM prices.
The considered battery storage has 5 MWh / 5 MW capacity. The round-trip efficiency is 0.81. Regarding the flexibility needs listed in Table 4

B. MODEL VALIDATION
The R-DLFM and P-DLFM market setups are modeled in the same manner to make comparable results. Depending on the chose budget of uncertainty in the IDM, activities in markets change and, consequently, overall profits differ. Prior to the analysis on how different values affect the battery storage's strategy and revenue, the models' validation and explanation is conducted with the value of budget of uncertainty zero, i.e. perfect foresight of the expected IDM trading success. Figures 4 and 5 show the battery's state of energy (SOE) and net charging/discharging activities for both market setups.   The battery starts and ends the observed time horizon with the same SOE for all scenarios due to constraint (16). Figure 5 illustrates only the net battery activity described with the equation (10) that summarizes all market activities, so a more in-depth analysis of the activities in different markets is needed to explore the arbitrage between markets within the same time periods. For the R-DLFM market setup, in all scenarios the battery is charged in hour 3, whose prices in all markets and scenarios are at the lower range as compared to the rest of the hours (see Table 3). In the same manner, the battery storage takes advantage of the high energy prices in all markets and discharges the battery in hour 8. Until the end of the day, the battery operation scheme follows the described strategy. Although in some hours the battery SOE stands is idle, energy arbitrage between different markets produces profit and is conducted in a way that the amount of energy purchased in one market equals the energy sold in another. Inter-market arbitrage is highly beneficial for the battery as it does not incur any energy loss due to roundtrip inefficiency nor it degrades the battery capacity.
Regarding the P-DLFM market setup, the same principles are valid as in the R-DLFM case but with a major differences that the P-DLFM clearing precedes the DAM clearing. Hence, the battery storage operator has different information availability and stochastic scenario tree structure, which leads to a somewhat different SOE profile. In the P-DLFM case, the battery's physical activity is much more expressed and there is a larger discrepancy between the scenario schedules than in the R-DLFM setup (graphs to the right in Figures 4  and 5). This is related to the fact that the P-DLFM prices are very attractive in comparison to the other markets, so as this market clears first, the battery storage operator's optimal strategy is to physically charge and discharge the battery exploiting the price differences within the DLFM market, while inter-market arbitrage is secondary source of revenue.
To examine the process of energy arbitrage deeper, Figures 6 and 7 focus on only one stochastic tree branch in the R-DLFM market setup with the value set to 0. Scenario [0,0] includes the high DAM, IDM, BM and R-DLFM prices listed in Table 3. The prices in all markets in Figure 6 follow the same trend, but with different amplitudes and ranges. In terms of arbitrage, hour 5 clearly demonstrates the inter-market arbitrage. The overall net battery activity equals 0, however, an arbitrage is happening between the DAM and the IDM. In hour 5, the IDM price is 27 e/MWh, while in the DAM 39.93 e/MWh (48% higher than the IDM price!). Figure 7 indicates that in hour 5 maximum charging is performed in the DAM and maximum discharging in the IDM. Thus, the profit is achieved without even physically using the battery.
The DAM can be used in R-DLFM to provide larger capacity in the DLFM. In hour 9 the net battery activity results in the maximum discharging power, i.e. 5 MW, motivated by the flexibility up demand. As the SOE cannot go under 0, the DAM was used to acquire enough energy so the battery can participate in the R-DLFM with 10 MW, which is double its power capacity. Thus, the up flexibility is achieved by cancelling the charging process at 5 MW scheduled in the DAM and instead discharging the battery at 5 MW.
The described actions in hours 5 and 9 indicate that battery storage gains major benefit by acting in different markets and performing inter-market arbitrage, which generates a significant profit and results in trading power capacities higher than the actual battery capacity. Purchasing energy in one market and then selling it in the other may result in zero, or at least lowered, actual battery charging/discharging, which extends the battery's lifetime. In other words, the battery operator sells energy in a market with higher price, while it buys it in the market with lower price in the same time period. Different scenarios bring different price relationships (differences) between markets, but in the end, the model follows exactly the same principles as shown in this example. Figures 8 and 9 show that the battery storage's expected profit decreases with the increase of the uncertainty budget, i.e. as the IDM prices during more time periods are damaged by the robust optimization. More specifically, the IDM prices are less favorable when both buying and selling energy, thus effectively reducing the battery storage actions in this market. Due to the reduced profit opportunities, the overall profit also reduces with the increasing values of the uncertainty budget. Having in mind that the same data set was used in both market setups (R-DLFM and P-DLFM), it is highly interesting to notice that the P-DLFM setup generates higher overall profits for the profit-oriented battery storage. For = 0, the R-DLFM profit is 1518e, while for the P-DLFM 1589e (4% higher profit). Although R-DLFM has the perk of easier integration into the existing power market structure, the P-DLFM setup has higher economic benefits to independent battery storage. This should be considered when opting for one of these two setups to be implemented in real-life systems. The maximum value of the uncertainty budget is 24,  i.e. all of the observed hours are then affected by unfavorable IDM prices. In that case, the profit in the R-DLFM sinks to 1079e (29 % decrease compared to the case when = 0) and to 1148e in the P-DLFM (28 % decrease compared to the case when = 0). Furthermore, comparing the R-DLFM and P-DLFM market setup when = 24, somewhat above 6% is higher profit for battery storage is achieved in the latter market setup.

C. ANALYSIS OF THE UNCERTAINTY BUDGET
Next, we analyze the behaviour of the battery storage in the DAM and the IDM for both market setups. Figure 10 illustrates similar trends both for the R-DLFM and the P-DLFM setups. As the uncertainty budget increases, the overall discharged, i.e. sold, energy in the IDM decreases because the prices are becoming less favorable. The expected energy sold in the IDM in the R-DLFM setup throughout the day decreases from 71 MWh for = 0 to 30 MWh for = 24 (decrease of around 58%). In the P-DLFM setup the energy discharged in the IDM decreases from 61 MWh for = 0 to 31 MWh for = 24 (decrease of around 50%). Thus, for = 0 the battery storage participates with higher amount of energy in the IDM in the R-DLFM case than in the P-DLFM case, however, the DAM charging (buying) activities are pretty similar (R-DLFM: 82 MWh, P-DLFM: 83 MWh). This is in line with the results presented in Figure 5 and the thesis that the inter-market arbitrage is much more emphasized in the R-DLFM setup. Furthermore, the DAM charging activity decreases in both cases with increasing uncertainty budget. In the R-DLFM setup the decrease is from 82 MWh to 55 MWh (33%), while in the P-DLFM setup the decrease is from 83 MWh to 61 MWh (27%). These results demonstrate that the effect of unfavorable IDM prices is more detrimental to the R-DLFM arbitrage strategy. Also, the IDM charged energy sinks in the R-DLFM setup from around 21 MWh to 14 MWh (33% decrease), while in the P-DLFM setup the reduction is from 25 MWh to 19 MWh (24%). One of the most important reasons why markets may face such notable decline in the battery activities for higher values is the fact that the battery does not have any lower bounds on the energy that it has to deliver, so the battery operator strictly follows the strategy that brings the highest profit without any obligations besides the reported charging/discharging schedule. The DA discharging in both cases increases with the higher budget of uncertainty for over 30%.
When it comes to the battery activity in the DLFM markets, Figures 11 and 12 show that P-DLFM setup stimulates higher utilization of flexibility service in comparison to the R-DLFM, regardless on the IDM uncertainty budget. Hence, when designing a new market structure, the trade-off will be between the ease of the integration (R-DLFM) and more intense activities in the local flexibility markets (P-DLFM). For both market setups the battery storage participation in the DLFM is inelastic to the values of the uncertainty budget, i.e. both up and down flexibility provision is (almost) identical regardless on the value of . Very attractive DLFM prices used in this case study are the main reason for the battery storage's interest in the DLFM. However, comparing the  R-DLFM and P-DFM market setups, both flexibility up and down service provision is at least double in the P-DLFM market setup than in the R-DLFM, although the demand and prices are the same in both cases. Moreover, out of the total demand, the expected up flexibility service provided by the battery storage in the R-DLFM setup is 41%, while in the P-DLFM setup it accounts for 83%. The explanation for this is that the P-DLFM precedes all the other markets.
For completeness, we mention the battery storage activity in the BM. Both for the R-DLFM and P-DLFM setups the battery activity is zero. The BM costs are so high that by all means in both market setups the battery storage tries to avoid the BM corrections to its market position. However, if the DLFM prices would increase, the battery storage operator might receive an incentive to deviate.
We conclude the case study with graphs that depicts the overall charging and discharging activities depending on the uncertainty budget. Figure 13 shows the overall charged and discharged energy quantity during the day for all possible values of the uncertainty parameter in the R-DLFM and P-DLFM setups. There is a constant difference between the charging and the discharging quantities in the graphs due to battery inefficiency. In the R-DLFM graph there is no clear trend to relate the charging/discharging energy and the budget of uncertainty. On the other hand, in the P-DLFM setup, an increase in the value results in reduced physical charging/discharging energy.

IV. CONCLUSION
After analyzing the available literature and ongoing trends in the modern power systems (i.e. power systems rich in distributed renewable generation and prosumers), we can conclude that flexibility will play a major role in the process of integration of the renewable energy resources and distributed paradigm. Both the academia and the industry identified distribution-level flexibility markets as an important mean of providing flexibility both at the local and the system levels. This paper formulated and analyzed two different DLFM setups. The R-DLFM is cleared between the DAM and the ID markets, while the P-DLFM precedes the DAM. R-DLFM is certainly a better fit to the current power market structures concerning the complexity of integration. Analyzing these two market setups, P-DLFM provides greater profit potential to the respective profit-oriented player. An important factor that needs to be explored in detail is the price formation for the flexibility market. Further research will be focused on the role of flexibility providers to the distribution system investment decisions by purchasing certain services from the local flexibility providers instead of investing in copper.