Constrained Optimization as the Allocation Method in Local Flexibility Markets

: Local ﬂexibility markets or smart markets are new tools used to harness regional ﬂexibility for congestion management. In order to beneﬁt from the available ﬂexibility potential for grid-oriented or even grid-supportive applications, complex but efﬁcient and transparent allocation is necessary. This paper proposes a constrained optimization method for matching the ﬂexibility demand of grid operators to the ﬂexibility supply using decentralized ﬂexibility options located in the distribution grid. Starting with a deﬁnition of the operational and stakeholder environment of smart market design, various existing approaches are analyzed based on a literature review and a resulting meta-analysis. In the next step, a categorization of the allocation method is conducted followed by the deﬁnition of the optimization goal. The optimization problem, including all relevant input parameters, is identiﬁed and formulated by introducing the relevant boundary conditions and constraints of ﬂexibility demand and offers. A proof of concept of the approach is presented using a case study and the Altdorfer Flexmarkt (ALF) ﬁeld test within the project C/sells. In this paper, we analyze the background of the local ﬂexibility market, provide the methodology (including publishing the code of the matching mechanism), and provide the results of the ﬁeld test.


Introduction
Local flexibility markets (LFMs) (also called smart markets) describe new platforms for the coordination and allocation of decentralized and often small-scale flexibility. This flexibility can be used inter alia for the congestion management (CM) of grid operators [1]. A variety of mechanisms are already being discussed in the international standardization [2] and a number of projects are currently developing such platforms. The main focus of these pilot projects is manifold, with some emphasizing economic requirements or regulatory compliance, and others following a greenfield approach and prioritizing technical feasibility. Therefore, there is a scientific gap between the consideration of practicality under the current regulatory framework and the significant technical added value through gridsupportive flexibile use.
In addition to the necessary process definitions, interfaces, and front-and back-end development, the core element of the LFM is its matching process. Within this paper, an allocation approach based on constrained optimization is proposed that considers both the flexibility demand of grid operators and the supply conditions of decentralized flexibility options. Additionally, the code of the matching algorithm is provided in the Supplementary Material. The supply and demand of flexibility are allocated considering external constraints and boundary conditions. These can be manifold, starting with locally differing effectiveness of the available flexibility on grid congestion, the inclusion of technical restrictions of the assets, regulatory compliance, and, finally, meeting the core objective of minimizing costs while ensuring maximum coverage of the demand. Current developments and recent research regarding grid-supportive flexibility use and development of LFM provide the foundation and starting point of this research. The novelty of this contribution is the comprehensible development of an approach based on initial demand specifications. It also proves and underlines the technical advances of this matching approach in comparison to existing projects and literature contributions where network constraints are neglected within the market area, detailed network simulations are necessary, or flexibility options are limited to large-scale assets. The initial consideration of the development process includes a pre-defined day-ahead process and the need for the integration of small-scale flexibility options. The latter are covered by an aggregation scheme that includes specific boundary conditions resulting from technical as well as regulatory constraints for the call of these assets. Furthermore, the yet-undefined role of the LFM operator and a potential external or joint operation necessitated keeping sensitive grid data undisclosed. This precondition was fulfilled using an a priori effectivity evaluation instead of detailed network topology. As a result, heuristic approaches such as power flow calculations were not considered. Therefore, there are several significant differences compared to most other markets (including the proposed LFM frameworks), where the intersection between supply and demand bids determines the optimal price and quantity. In contrast to existing matching mechanisms in established, conventional energy market environments and the regional order book approaches in other LFMs, the additional complexity through several restrictions is system-immanent [3]. As these cannot be considered in approaches merely based on merit order lists, a fundamentally different approach is necessary. Especially for lower voltage levels, where location-specific flexibility demand is met with limited and technically diverse flexibility resources, a novel allocation method is essential. A comparison of the proposed approach to alternative, heuristic matching algorithms conducted in [4] within a generic case study resulted in similarly efficient flexibility allocation, combined with less computational effort and reduced data usage. The two heuristic approaches presented in [4] are based on merit order lists and subsequent load flow calculations that determine and evaluate the impact of the offer bids. The first algorithm directly uses the input of the merit order; the second further adds a preprocessing function that weights the individual bids with their respective technical effect.
In contrast to other publications, e.g., [5][6][7], the focus of this contribution is a detailed description of the proposed approach and its proof of functionality, and not a mere comparison of different approaches. Our intention is to provide an alternative and potentially more efficient optimization-based allocation method that complies with the identified technical and market demands as well as current regulatory requirements. The optimization problem of the proposed LFM is derived and formulated on the basis of an analysis of market design requirements as well as a differentiation from existing approaches. Based on these considerations, this paper addresses the following research questions: • RQ1: How is the optimization problem defined, including all necessary requirements and boundary conditions? • RQ2: What parameters and constraints need to be considered to reach the optimization goal? • RQ3: How does the proposed approach differ from existing LFM matching designs? • RQ4: Can the matching algorithm prove its applicability in a realistic situation? Figure 1 further illustrates the proposed methodology as described in the following sections.
Starting with a detailed description of the application environment in Section 2, the concept of market-based approaches for grid-supportive flexibility is defined. Section 2.1 evaluates the specific requirements and particularities of LFM by comparing it to other market frameworks. A literature review and meta study on allocation methods in Section 2.2 introduces recent developments, the current state of the science, and an overview of existing LFM projects. Section 3 finally describes the motivation of the optimization-based matching process, with its optimization goal defined in Section 3.1. A description of flexibility demand and offer (Sections 3.2 and 3.3) and the considered product types lead to the deduction of relevant boundary conditions (Section 3.4) that need to be considered within the necessary constrained optimization. The resulting optimization problem is formulated in Section 3.5, including constraints and relevant parameters. In the next step, the application of the proposed setup to the real field test of the Altdorfer Flexmarkt (ALF) (Section 4) is described, including a description of the relevant interfaces and data formats (Section 4.1). In Section 4.2, an example of implementation is illustrated using sample data. The corresponding program code is further provided as auxiliary data. The following critical review in Section 5 illustrates the potential room for improvement and the need for further research. The paper concludes with a summary of the contents and illustrates the relevance of this contribution in Section 6. Furthermore, an outlook to ongoing and planned research is provided.

Market Design of LFMs
An efficient LFM market design intends to provide an interface between grid operators and flexibility in the network. In this context, (active) flexibility is understood as the technical ability of a system to change (increase/decrease) its current and predicted power [P, Q] based on an (external) signal. The ability to provide active flexibility results in the need for suitably flexible products (Section 3.3). A flexible energy system with such technical ability is defined as a flexibility option (FO). FOs include both controllable generation and consumption units, as well as storage facilities that can be switched on and off by an external signal. Therefore, the FO needs a communication module such as a smart meter. For the targeted use of flexibility, the location (i.e., the connection point in the grid area) and the associated radius of action are important [8].
By using a market-based approach (combined with regulated aspects if necessary), the cost-optimized, secure, and reliable use of flexibility is possible. Finally, the overall goal is to improve the grid operation by taking advantage of local flexibility potentials in order to reduce feed-in and consumption peaks. An LFM can optimize the existing CM processes by coordination and use of decentral flexibility across several grid levels. Furthermore, it expands the processes of CM through the integration of additional options [9].
The schematic concept of LFMs as understood in this context is shown in Figure 2. Demanders and providers of flexibility as primary participants on the market platform are briefly presented in the following. Grid operators act as flexibility demanders. They can use LFMs as an operational planning tool to contract flexibility in response to predicted grid congestion, in addition to the established CM measures. Their intention is to reduce dependency on emergency measures for congestion management. In the case the grid operator determines a need for flexibility within its day-ahead load flow and network safety calculations, the determined flexibility demand includes the amount of predicted overload on a specific grid location.
Flexibility providers represent owners, operators, and marketers of FOs, who offer their flexibility on the LFM. To incorporate as many FOs as possible in the market, diversified product options are required, including variable energy pricing and compensations [10].
The platform operator is responsible for the functioning, maintenance, and further development of the LFM platform. This includes the provision of server infrastructure, support service, and personnel. Nevertheless, the actual role and its regulatory obligations have not yet been officially defined.
Regarding the considered time frame, the predicted flexibility demand is submitted within the day ahead, allowing the determination of an optimized allocation of flexibility in advance. Once flexibility demands and offers are submitted to the platform, the allocation is scheduled and determines which flexibility providers will be activated.

Grid-Oriented Flexibility Allocation as Matching Markets
In most existing energy markets (i.e., the intraday or day-ahead spot markets), price is the only considered allocation parameter. Due to the following reasons, this is not applicable within LFMs:

1.
The topological grid location of available flexibility is relevant to solving specific congestions and has to be integrated in the matching.

2.
Many flexibility calls are associated with boundary conditions. 3.
The reliability of the flexibility call is essential for the demand side: congestion management measures are defined as emergency measures. A market-based solution has to meet strong requirements in planning security.
Roth [11] described this type of market that considers more specific quality aspects of a product as a matching market. Applied to LFMs, the allocation method includes the consideration of several aspects on both sides (congestion and the available flexibility in the grid) as follows: 1.
Offered price for flexibility, which can be individually specified by the plant operators for each time step in schedule offers (see Section 3.3.1).

2.
Available power for every 15 min slot of the contraction period (i.e., the next day), which is provided by the active marketers or determined by the aggregation algorithm for long-term contracted asset pools (see Sections 3.3.1 and 3.3.2).

3.
Constraints and boundary conditions regarding power and call restrictions that can be further voluntarily indicated for schedule offers or are predefined by the platform as a condition of participation for long-term contraction (see Section 3.4).

4.
Effectiveness of flexibility offered to the congestion, which is defined as the impact of power adaption to the overloaded grid component by the resulting change in current or voltage. Therefore, an approach to determining a linearized relation between the congestion and flexible assets without the need of continuous load flow calculations and grid data was developed, as described in [8] (see Section 3.4).
One possibility for an LFM is the regional order book, which is, for example, used in the enera flex market (see [12] and shown in Table 1). A regional order book adapts the processes from whole-sale markets to regional markets. A considerable advantage of this procedure is the easy implementation by the use of well-known mechanisms: the enera flex market basically uses the processes of the day-ahead market of the EPEX Spot SE, Paris, France.
Based on the stakeholder analysis in Section 2 and the defined requirements, a different approach was chosen due to several reasons: 1.
A regional order book assumes a constant effectiveness of all FOs on the congestion. According to [8], the effectiveness in a mid-voltage grid varies significantly and has to be integrated in the matching process.

2.
In a regional order book, the traded flexibility is the deviation from a baseline. In this case, it is not possible to consider restrictions of the supply side. 3.
From a system perspective, an optimal matching solution on the LFM must be found not for a specific point in time, but for a time period (i.e., the entire day of contraction with 96 time steps of 15 min each in a day-ahead market process), while considering the restrictions of flexibility offers and demands. Therefore, an iterative determination of the optimum combinations of flexibility offers is necessary to efficiently meet the demand.
The next section provides an overview of the relevant basics that are found in the literature as well as a meta study regarding allocation approaches in existing market setups.

Literature Review and Meta Study on Allocation Methods in Other LFMs
Within the following selection of relevant studies and publications, various allocation methods in existing smart market environments are described.
Structured reviews from recent literature related to flexible resources and trading structures in various application levels of smart grids can be found in [5][6][7]. The latter provides an overview of different clearing and allocation methods. The evaluated application levels refer to flexibility use at the transmission system operator (TSO), DSO, or customer level. Further classification of flexibility market designs, implementations, and related products considering the main attributes, such as scope, purpose, location, or provider, is presented.
In [13], a general description of local flexibility market design is provided. In addition, an approach to providing multiple flexibility services at the distribution network level is described. Within the framework described in [14], flexibility trading mechanisms are standardized to foster platform integration of markets and products. Therefore, a separation of the market operator role from the product owner (TSO and DSO) is intended.
Several sources provide specific LFM market design proposals. Ref. [15] analyzed LFMs together with other policy approaches for congestion management regarding their economic functioning and evaluated them against a theoretical benchmark. Ref. [16] identified and evaluated three coordination and market mechanisms for procuring flexibility services: a sequential mechanism (each party on its market), coordinated Shapley value allocations for TSO and DSO, and a joint TSO-DSO-retailer mechanism. Ref. [17] discussed flexibility market design proposals in terms of temporal, spatial, contractual, and priceclearing dimensions using three main contraction approaches: through the existing whole-sale markets, through a separate flexibility platform, and through a reserve-type market approach. Ref. [18] constructed an integrated market-based active system management approach from a grid operator's perspective integrating flexibilities owned and operated by third parties. This also includes requirement definitions for offered flexibility, products, and bids. Ref. [19] proposed an integrated flexibility market concept combined with bilateral energy transactions in potential future peer-to-peer markets.
Regarding its technical impact, LFMs have been further evaluated regarding their efficiency in solving grid congestions. Ref. [20], as one of few publications, tried to assess demand-side flexibility versus physical network expansions in distribution grids in order to find an optimal combination of these two options. Several studies focused on flexibility allocation methods in general, but also proposed matching algorithms in particular. Ref. [7] classified existing optimization models for LFMs into four categories, i.e., central optimization models, game theory-based models, auction theory-based models, and simulation models. Ref. [21] reviewed works dealing with matching management models through autonomous software agents. Ref. [22] describes an optimization problem to meet the DSO's need for flexibility based on a decision-making problem. In [23], a simple optimization model of a day-ahead clearing algorithm is presented. With the aims of minimizing the DSO's total cost of acquiring flexibility, energy rebound effects are considered. Ref. [24] shows a decentralized implicit interaction framework that includes two timeframes (day-ahead and intraday) that is solved through a proposed hierarchical, bi-level optimization. Ref. [25] suggests an optimization model for coordinating ancillary services based on multi-flexibility measures in order to facilitate interaction between the power grid and a distributed energy system. Ref. [26] considered and evaluated a concept for DSO overload management using a two-part tariff service market modeled as a threestage stochastic market including day-ahead, intraday, and real time. Ref. [27] presents a flexibility integration process using dynamic pricing under mass-application circumstances.
As stated, there are several LFM platforms currently in development, with some of them already operating. Comprehensive reviews of European proposals have been published [28,29]. Ref. [30] depicts different flexibility market approaches and barriers, focusing on market designs, platform types, implementation specifics, and the need for regulatory adaptions.
Depending on the application level or its main purpose (i.e., information, coordination, stage of regulation, or open market platform), the market design of these platforms differ significantly. Therefore, not all of them provide a distinct allocation method in the sense of matching demand and supply on the platform. Table 1 provides an overview of the selected flexibility platform concepts.  [10,46] As illustrated, the allocation of flexibility demand and supply can work in various ways depending on the platform and project focus. As most platform approaches focus on schedule-based flexibility products, current technical limitations of small-scale flexible assets like heat pumps or decentralized renewable energy resources can not be considered in an appropriate way as these are not able to provide active marketing. Platforms using order book mechanisms assume non-congested market areas which reduce market liquidity and make it also impossible to address congestions in the lower voltage levels. Approaches involving the DSO as market operator use optimal power flow (OPF) simulations combined with an economic evaluation to assess an ideal flexibility contraction. Regarding the time frame of the market process, day-ahead as well as intraday flexibility contraction prevail. In general, the higher the addressed voltage level, the more short-term trading is considered. Generally, it can be observed that there is no "one-size-fits-all" solution, but the concept has to be adapted to the conditions of the project scope. Within this paper, the focus lies on the development of a market-based scheme in CM on DSO level under consideration of the specific characteristics described further in the following chapter. The following passages present an approach that is directly derived from the the actual technical, economical and regulatory needs.

Matching Flexibility Demand and Supply through Optimization
A market can generally be defined as a place where supply and demand for a good are matched in price and quantity [47]. In the case of a nLFM, however, further aspects need to be considered in the matching process. The concept developed in this paper is based on several preliminary works as well as joint workshops with distribution system operators (DSOs), aggregators, and potential flexibility providers that led to the identification of the requirements stated above. In particular, the aspects presented in the previous section, including inhomogeneous effectiveness values, differing price offers, and available power, necessitate constrained optimization in order to find a techno-economic optimal solution for the defined time period.
Following the classification in [7], an auction-theory-based approach best meets the aforementioned needs. Auctions define a rule-based market mechanism through which resource allocation and prices are determined on the base of bids from auction participants [48]. Regionalized LFMs can be modeled as a double-sided multi-attribute combina-torial reverse auction. The following list elaborates the term's constituents to confirm the suitability of that specific modeling approach.

1.
Reverse auctions are characterized by the inverse roles of sellers and buyers compared to a traditional auction. Here, the sellers constitute the bidders, while a buyer wants to acquire a resource for the lowest possible cost.

2.
Combinatorial auctions allow bids for combinations of heterogeneous goods. This is necessary, as flexibility is considered a heterogeneous product due to its multiple attributes such as capacity, ramp rate, duration, or lead time [48,49]. 3.
Multi-attribute auctions are required, because in addition to the price, flexibility bids are characterized by the aforementioned constraints, i.e., effectiveness, available power, and boundary conditions. 4.
Double-sided auctions typically feature multiple buyers and sellers. Concerning regionalized LFMs, the buyer side involves several DSOs demanding flexibility for congestion management.
As a flexibility demand can be fulfilled by multiple FOs, it is necessary to consider a price-clearing mechanism for paying bidders with different bid prices. Two common approaches are pay-as-bid and uniform pricing [48]. Due to the nonhomogeneous nature and fragmentation of flexibility products, for which uniform pricing cannot account, the pay-as-bid price is considered superior for modeling LFMs [49,50].
Based on the auction model, the optimization problem lies in determining the winner of the auction, i.e., identifying the allocation of resources by bidders while reaching a predefined optimization objective. This problem is commonly referred to as the combinatorial auction problem (CAP) and can be formulated as a mixed integer problem (MIP). The subsequent sections discuss the optimization objective and relevant boundary conditions in order to formulate the optimization problem in the following section.

Optimization Goal
The optimization objective is to minimize the total costs for relieving congestion. As part of the formalized optimization problem, this goal needs to be reflected in the objective function. The constraints of the problem need to address all limitations. Furthermore, the effectiveness parameters need to be considered. The objective function seeks the optimal solution in order to achieve the following two goals:

1.
Minimize operating costs: The goal is to minimize the overall operating costs. This is represented by the objective function where the sum of all operational costs is minimized, while 2.
Simultaneously meeting as much of the demand for flexibility as possible: By only minimizing costs, it is impossible to reach a satisfying market result, as the cheapest option would always be not contracting anything at all and therefore resulting in costs equal to zero. However, attempting to always exactly match flexibility demand might result in disproportionately high costs. Therefore, demand fulfillment is not formulated as an equality constraint but rather incorporated into the objective function via a penalty factor. This approach is valid as flexibility demand includes a certain degree of elasticity. In the case of critical network conditions, DSOs have other contingency measures for resolving grid congestion available to them, which are independent of the flexibility offers. Accordingly, they are not forced to draw disproportionately expensive FOs.
To gain a better understanding of the aforementioned needs, the following sections describe relevant input from both demand and supply sides.

Flexibility Demand
The grid operator submits its flexibility demand to the platform in order to resolve predicted grid congestion. The data contain all affected grid components in terms of current and/or voltage problems. Both congestion types need to be resolved in 15 min intervals, resulting in 96 time steps per day. For instance, a thermal overload would result in a current problem with a corresponding flexibility demand measured in amperes at a grid component for a specific time step. The chosen day-ahead process therefore coincides with the approach followed by most DSO platforms in Table 1.

Flexibility Offers and Products
Unlike flexibility demand, flexibility offers differ in several aspects depending on the marketing type and the properties of the FO, which are presented in the following sections. Therefore, the differentiation between flexibility providers who are able to actively place flexibility offers on the platform and providers who lack this capability is necessary. The two options are reflected in the following proposals for flexibility products. Furthermore, product options and classification metrics can be found in [10].

Schedule Offers
Schedule offers define the standard product, providing professional marketers with the possibility to actively place offer bids on the platform. Actively marketed FOs have preplanned working points, the so-called baseline. These are required for electricity trading, supply contracts, or balancing group management, for example. Therefore, a day-ahead time series in 15-min steps is needed, including available positive and negative flexible power, energy, and price, respectively. In addition, potential call boundary conditions need to be considered (see Section 3.4). Existing data standards, as defined within the KWEP-process, provide orientation for the development of the bid format [51].

Long-Term Contraction and Aggregated Offers
Long-term contraction defines an alternative for including small flexibility units in the marketing process. In contrast to schedule offers, this does not require frequent interaction with the platform by uploading new bids. Instead, this option only needs a single-time authorization. This encourages participation through a minimal market entry barrier, and targets assets without the ability of active marketing such as small PV plants, heat pumps, or storage heating. As such, the platform is granted access to control the FOs within defined boundaries. Depending on the type of FO, an aggregation process will subsequently pool similar available units in topological (i.e., regional) proximity to each other. Therefore, the pooling method depicted in [52] results in pools of similar effectiveness for a potential grid congestion. These pools allow a stochastic prediction of available flexibility for each time step calculated based on type-specific factors, e.g., daily mean temperature for heat pumps. Combined with boundary conditions given by the long-term contraction (see Section 3.4), an aggregated offer in the same format as a schedule offer can be submitted to the platform for each pool.

Boundary Conditions
The boundary conditions determine the constraints of the optimization problem and result from different FO properties, which is discussed in the following sections.

Technical Boundary Conditions of Flexibility Options
FOs can be called at different levels depending on the plant type. In this paper, three different plant types are considered regarding their available call levels, as shown in Figure 3.
Binary controlled (0/1) plants only have the two operating states, On or Off. An example of this is an aggregated pool of heat pumps, where the availabilities can only be determined stochastically (see Section 3.3.2) [52].
All systems that were created as a result of the German Renewable Energy Sources Act (EEG) of 2000 belong to the second system type (e.g., PV plants or wind turbines). These renewable energy plants have four potential production levels (0%, 30%, 60%, and 100%).  Lastly, some plants have no discrete production levels and can increase or decrease their power output progressively according to a schedule. Limitations apply only to the maximum power output or intake. Power restrictions can take the form of both negative and positive values. An example of scheduled plants is energy storage devices.
All different call levels of these plant types are considered as constraints in the optimization problem.

Call Restrictions of Flexibility Offers
Boundary conditions for the optimization problem can also be derived from the technical limitations of the FOs. This particularly applies to aggregated offers resulting from pooling long-term contracted FOs (Section 3.4). In addition to the power restrictions, restrictions exist on the duration of a call, the minimum time between two calls, the total call duration during a day, plus the total number of calls per day. The call restrictions are shown in Figure 4.

Consideration of Localities via Effectivity Values
Another unprecedented aspect to LFM matching in the proposed allocation scheme is the deliberate independence of platform operation from the need to possess detailed grid structure information. This has several advantages regarding the independent role of the platform operator or even potential joint platform operation. Since the actual impact delivered to the flexibility demand after activating a FO can vary depending on the grid structure, sensitivity is determined in advance. The impact of a (active) power adjustment at all relevant grid connection points is therefore evaluated through the responding change in current or voltage at all relevant grid components. The approach, resulting in an effectivity matrix to determine this effect of flexibility provided to grid congestions, is presented in [8]. This includes a technical grid evaluation in order to compute the impact of flexible assets. Finally, a linearization of the impact factor is conducted in order to approximate and evaluate the effect of flexibility to the LFM without providing detailed and sensitive grid data. The factor then can be provided for the addressed grid point and the considered FO in A/kW or V/kW, respectively.

Definition of the Optimization Problem
After defining relevant input data, the next step in developing the matching process is the mathematical formulation of the optimization problem, including the optimization goal, boundary conditions, and decision variables. Decision variables x cover the contracted power call P ij for every available FO. As the call levels for certain plant types cannot be continuously adapted, the corresponding variables are restricted to being integers. Therefore, the optimization problem, containing both real-number and integer variables, falls within the domain of mixed-integer programming.
By nature, flexibility platforms compensate for positive and negative power calls from FOs. However, considering this via absolute values results in a nonlinear problem. Again, nonlinearities pose several challenges that impact the efficiency of market processes, mainly reflected in increased solving times and lower-quality results compared to linear problems [53,54]. To avoid these pitfalls and maintain linearity, decision and auxiliary variables are introduced that differentiate between positive and negative values. The objective function of the optimization can then be described according to Formula (1) considering the variables defined in Table 2 alongside cost and penalty parameters C ij and G lj . Note that the demand fulfillment constraint from Section 3.1 is incorporated into the objective function via an additional penalty term. This way, over-and underfulfillment of the flexibility demand d jl is not prohibited, but causes additional costs in the optimization. However, this formulation does not lead to an unconstrained problem, as more dependencies need to be considered. The deviation from the actual demand is described in Equation (2), considering the specific effectivities of the FOs provided. The matching process further takes into account all other constraints and boundary conditions resulting from the specifications of supply and demand. These include the following:  (4) and (5)) -Minimum duration of a call (Equations (6) and (7)) -Minimum time interval between two calls (Equations (8) and (9)) -Maximum call duration per day (Equation (10)) - Possibility of partial performance of the offer including discrete call levels (e.g., 0%, -30% -60%, and -100%; Equation (11)) -Minimum and maximum retrievable power (Equations (12)- (15)) These additional constraints are shown in the following equations in Table 3 containing the variables defined in Table 4. Table 3. Additional constraints to the optimization equation.

Equation Description
Simulation of non-fulfillment of demand considering specific effectivities.
The sum over all state switches plus the state of the FO in the first as well as the last time step must not exceed twice the number of allowed calls.
After activation, a FO can remain switched on for a maximum time period. The first condition covers the case that the FO is activated in the first time step, while the second condition deals with later activations.
Depending on the moment of activation, the two conditions ensure that FOs remain activated for a minimum defined time period.
After a call of a FO has occurred, the FO in question must remain deactivated for a defined blocking time. The second condition extends this constraint to blocking times remaining from the previous day.
The total call duration per day must not exceed a defined limit. The factor 1 4 accounts for 15-min intervals.
In the case that FOs do not feature continuous power modulation, discrete switch settings (e.g., 0-30-60-100%) must be considered.
In the case of continuous power modulation, minimum and maximum power restrictions must not be violated. The four conditions cover the lower and upper bounds for power increase and power decrease.
The mentioned effectiveness evaluation (see above) is determined in the form of the parameters e ijl . so that ∑ m j=1 ∑ n i=1 e ijl (P + ij + P − ij ) corresponds to the effective performance. The values of e ijl finally represent the actual grid structure without disclosing detailed network topology data. but an effectivity matrix that is determined a priori (see Section 3.4). In addition, further auxiliary constraints, e.g., to prevent both positive and negative power being contracted in the same time period, are defined but not explained here in detail.

Altdorfer Flexmarkt (ALF) Case Study
Within C/sells, different LFM solutions were explored, resulting in the C/sells-FlexPlattform [9]. One implementation of the C/sells-FlexPlattform is the Altdorfer Flexmarkt (ALF), an LFM with a distinct focus on providing an innovative tool for (distribution) grid operators to efficiently operate their existing grid [55]. ALF was developed and implemented by the Forschungsstelle für Energiewirtschaft (FfE) together with the DSO Bayernwerk. Its goals are as follows: • Access to existing small-scale flexibilities (i.e., heat pumps, electric vehicles, or small PV systems) and development of suitable flexibility products. • Market entry for unused flexibility: integration of flexibilities without market access today. • Technical realization of the process chain: the project intends to show the proof of concept of the technical setup and the performance of the smart meter infrastructure [56].
A detailed description of the project scope and its technical implementation can be found in [57,58].

Field Test Setup and Application on Medium-Voltage Grid in the Project Region
Regarding the technical implementation of ALF, the requirements fulfilling the previously mentioned goals were integrated in the platform development. This included a transparent definition of the interfaces to the involved components, i.e., real-time grid safety calculations, prognosis data provision, and communication with an active external market participant. The LFM platform was implemented in the Python programming language in combination with a Django-based web front-end. In addition, a Google Android application was provided to the field test participants. In addition, technical user interfaces were defined and implemented for the provision of demand and offer bids, prognosis data, or active machine control through smart-metering infrastructure.
Regarding the provision of demand and offer bids, standardized file formats were defined to provide uniform interfaces. The contents of an example demand file are shown in Figure 5.
were defined and implemented for the provision of demand and offer bids, prognosis data, or active machine control through smart-metering infrastructure.
Regarding the provision of demand and offer bids, standardized file formats were defined to provide uniform interfaces. The contents of an example demand file are shown in Listing 1.  Table 5 illustrates the data format used to provide flexibility demand to the LFM. In addition to the demanded data, described in Tables 2 and 4, the plant's power baseline P BL and potentially available negative/positive energy E − /E + can be provided. The baseline P BL is used downstream in the settlement process of the LFM platform. The provided available energy is currently neglected in the matching process as this is compensated by the additional call constraints. The template already contains these additional datasets in compliance with the available standards. In addition to the provided interfaces and processes defined in the field test, the following section illustrates a simplified implementation example of the program code using sample data.

Implementation Example
To solve the now mixed-integer linear optimization problem, we provide an implementation example. For this purpose, a Python-based interface for commercial and non-commercial solution software called Pulp (v. 2.3.1) was used. This allows users to switch between solvers like CPLEX, GLPK, or the open-source variant CBC, without the need for a new implementation. As the interface for many solvers is similar, modularity is achieved by writing the model to the standard LP or MPS file formats. In the case of ALF, GLPK 4.65 is used under the GNU General Public License to solve the optimization problem. The GLPK solver naturally resorts to a branch and bound algorithm to solve the resulting MIP. Enhancements to this algorithm include cutting-plane strategies and variable node selection to increase performance. Table 6 shows a stripped-down example of  Table 5 illustrates the data format used to provide flexibility demand to the LFM. In addition to the demanded data, described in Tables 2 and 4, the plant's power baseline P BL and potentially available negative/positive energy E − /E + can be provided. The baseline P BL is used downstream in the settlement process of the LFM platform. The provided available energy is currently neglected in the matching process as this is compensated by the additional call constraints. The template already contains these additional datasets in compliance with the available standards.
In addition to the provided interfaces and processes defined in the field test, the following section illustrates a simplified implementation example of the program code using sample data.

Implementation Example
To solve the now mixed-integer linear optimization problem, we provide an implementation example. For this purpose, a Python-based interface for commercial and non-commercial solution software called Pulp (v. 2.3.1) was used. This allows users to switch between solvers like CPLEX, GLPK, or the open-source variant CBC, without the need for a new implementation. As the interface for many solvers is similar, modularity is achieved by writing the model to the standard LP or MPS file formats. In the case of ALF, GLPK 4.65 is used under the GNU General Public License to solve the optimization problem. The GLPK solver naturally resorts to a branch and bound algorithm to solve the resulting MIP. Enhancements to this algorithm include cutting-plane strategies and variable node selection to increase performance. Table 6 shows a stripped-down example of the matching process for three FOs, differing in their maximum available power and costs. Additionally, three-sided conditions were incorporated in the setup (T sum 1 = 4, T max 2 = 2, and C 3,4 = 100), which will be explained in detail while evaluating the result. The calculation example refers to a radial network. Due to their topological vicinity, the three FOs were evaluated with an equal effectivity factor of e = 0.03 A/kW. to 100 e/MWh. For the example, the penalty factor G = 1000 was chosen so that underfulfillment of the flexibility demand occurred. In this case, the DSO would have to resort to contingency measures beyond the flexibility platform to resolve the congestion. • In the last time step, the costs of FO 3 reduce to its default level and the power ramps up again to full capacity. The flexibility demand cannot be met 100% because the third constraint becomes active. T max 2 = 2 forces FO 2 to be switched off after two subsequent time steps of operation, so that its capacity is unavailable when resolving the congestion.
The program code for this example is provided in the auxiliary dataset of this publication. Variable and parameter nomenclature in the program code correspond to Tables 2 and 4. The results in Table 6 were obtained using the GLPK solver.

Critical Review
The presented optimization-based allocation method of flexibility demand and supply proved its function and efficiency in several laboratory and field tests. Nevertheless, there is still room for improvement and further research. From a technical standpoint, the following selected issues were identified: • The matching algorithm currently neglects the energy component of the flexibility offers. Although this aspect is intercepted via additional boundary conditions, energy constraints may offer added value, especially for storage facilities. • Penalization of demand over-and underfulfillment is still defined by a uniform value. In order to adapt to realistic market and demand behavior, a differentiation between allowed overfulfillment and avoidable underfulfillment may be beneficial. • Furthermore, a limitation on maximum costs has not yet been implemented. Limiting maximum costs to avoid exorbitant costs may be realized by an additional constraint, setting a cap on the costs of the activated power of all FOs per time step and demand. This cap can prevent price gouging by a supplier possessing market power due to a lack of alternative solutions to a given congestion. • The general potential for market manipulation due to market design inconsistency and market power tendencies needs to be observed. The potential of mitigation mea-sures within LFM were discussed previously (see [59,60]). Nevertheless, a consistent evaluation of dynamic market behavior still demands further research. • As typical for a day-ahead process, uncertainty remains in the forecast of the demand and the offers. Therefore, it is possible that the result of the matching does not perfectly fit the actual grid load: -From a demand perspective and the grid operator's point of view, this topic is not critical: an LFM is an additional tool in the congestion management of the grid operators. The already established mechanisms remain as emergency measures.

-
For the flexibility offers, it is conceivable that a prequalification process (e.g., balancing power) is integrated in the LFM as part of the registration. Furthermore, a penalty for non-fulfillment can be considered. The described project focused on the technical proof of concept and does not provide detailed settlement processes.
One open question is the long-term effect of LFM on the strategic bidding behavior of flexibility offers. The described mechanism aims at flexibility options that are not actively participating in energy markets in the current regime. Therefore, in a first step, there is no interdependency of flexibility on the LFM with the other use cases. In a second step, the flexibility on an LFM can also be used for the energy spot market or for balancing power-the decision will likely be selected based on the best outcome. In that case, several developments are possible: • Flexibility on the LFM is highly regulated and there is no real competition with other use cases. In this case, the LFM can be seen as an additional tool for the grid operators with regulated, cost-based pricing. • The LFM competes with other use cases. This opens the door to strategic bidding (and possible inc-dec gaming; see [59] for a detailed discussion).
The integration of LFM within the current energy system is an open research question where several design options are conceivable. Regarding the actual market design of the LFM, the proposed allocation method represents one solution for matching grid-supportive flexibility with demands. In [4], the present approach was already compared to alternative, heuristic matching algorithms to allocate network-supportive flexibility in a generic case study. In summary, the proposed concept offers an efficient method of considering all necessary requirements defined in Sections 1, 3.1 and 3.4. It further proved its application in realistic network environments as illustrated by an implementation example in Section 4.2.

Conclusions and Outlook
We provided a detailed description of a proposed constrained optimization algorithm as an allocation method for LFMs. Based on a general overview of market design, we depicted the overall goal as well as relevant stakeholders within LFM environments. The general framework for the development of market design was set considering stakeholderspecific and technical requirements. By analyzing relevant literature, the current state of science and technology was described, followed by a meta-study of selected LFM concepts. Furthermore, the differentiation from comparable concepts was described.
Starting from these preliminary works and framework definitions, the optimization problem was derived and the optimization goal formulated. Input parameters, through defined flexibility demand and offers, resulted in boundary conditions and constraints. In the next step, the objective function and all relevant constraints to the optimization equations were formulated mathematically.
Lastly, we concluded with a presentation of an actual application of the proposed LFM framework using a case study of Altdorfer Flexmarkt (ALF). The field test setup was further described, including its technical implementation and definition of interfaces and data standards. In this context, an implementation example was presented and the corresponding program code was provided. We proved the applicability of the suggested approach, which provides an efficient method for integrating the identified needs and boundary conditions from the demand and offer perspective. Furthermore, we achieved the initially objectives of integrating small-scale or aggregated flexibility options, keeping sensitive grid data undisclosed, and addressing congestions in lower voltage levels.
As a general summary, the specifics of the proposed allocation method are the result of an integrated design approach considering the current energy market design and role model. The proposed LFM was not created on a regulatory greenfield, but rather as further development of the current system.
As an outlook, several aspects regarding the integration of LFMs and the current developments (in Germany) regarding Redispatch 2.0 with other aspects of grid operator coordination are prospective fields of research that will be included in future projects. Furthermore, large-scale field tests, including the analysis of agent behavior, are necessary to better understand the market dynamics, not least for providing resilience toward market manipulation options. Funding: The activities described within this paper are part of C/sells, a joint project carried out as part of the Federal Ministry for Economic Affairs and Energy (BMWi) funding program Smart Energy Showcase-Digital Agenda for the Energy Transition (SINTEG-funding code 03SIN121).

Informed Consent Statement: Not applicable
Data Availability Statement: The program code presented in this study is available in the supplementary material.

Acknowledgments:
The authors would like to thank all project colleagues and, namely, the following contributors for their preparatory work to this publication: Julia Kowalczyk, Thomas Estermann, Andreas Bruckmeier, Vincenz Regener, Christina Lang, Miguel Guse, Julian Bierig, and Ryan Harper. Further thanks go to the reviewers for their valuable input and constructive feedback.

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

Abbreviations
The following abbreviations are used in this manuscript: