## 4 Proposed Approach: Quantitative Assessment of the Flexibility
### Assessment of Price/Quantity Curves at the TSO/DSO Interfaces  
Figure 1 shows the flow chart of the second task of the proposed approach. For a given distribution network (e.g., one single feeder) and for each considered time interval (t = t\({}_{0}\cdots\)T), the quantitative assessment of the distribution system market potential is obtained by performing the following steps:  
1. Calculate the maximum variations in upward and downward offers of the expected working point at the TSO/DSO interface by considering the hypothesised participation profile of each DER (i.e., maximum/minimum local generation and the minimum/maximum demand). Thus, the most extensive range of potential bids of the virtual power plant at the TSO/DSO interface is defined.
2. Represent the range of the upward and downward offers with a fair number of points.
3. Perform power flow (PF) calculations to verify the compliance of the distribution grid operation with the technical constraints by applying the generation/load conditions corresponding to the points obtained in the previous step 2. The PF calculation is performed on the given real distribution network if the data are known or, otherwise, on its synthetic model.  
1. If no violations are found, the relevant flexibility can be used by TSO with no adjunctive cost than the one correspondent to the price of the bids times the quantity purchased (i.e., _pay as bid_, they will receive a green traffic light).
2. If operational issues are found (e.g., voltage regulation and power congestions), an OPF calculation is performed to identify the optimal setpoints of local resources required to fix such distribution issues. In the early phase of the local flexibility market, only reactive power support can be used to solve the distribution system operational issues (i.e., the reactive support is used for voltage regulation issues, and it is more effective in networks with a high X/R ratio). The OPF aims at minimising the distribution system operation costs that have to be added to the price of the active power bids that, if awarded, can be accepted with reserve by the DSO (i.e., they will receive an orange traffic light).  
each line current concerning the unitary active (reactive) power variation from each single flexibility provider [42]. Additional constraints are the maximum flexibility that each DER can provide.
* It may happen that, in particularly critical distribution networks close to their hosting capacity, some operational issues (e.g., overvoltages, power congestions, excessive voltage drops) cannot be solved by resorting to the local resources. In such cases, the flexibility that can be offered to the TSO is limited by the distribution constraints. The difference between the potential bids calculated in step 1 and that resulting from eliminating the critical working points represents the measure of the non-feasible bids. DERs can bid such offers to the service market, but, if awarded, they will be blocked by the DSO (i.e., they will receive a red traffic light).  
The result of this methodology is the price/quantity curves for upward and downward offers from a distribution network portion for each time interval considered. The extra costs possibly sustained for the flexibility products or the blocks imposed by the DSO for avoiding harmful impacts on the distribution network operators are also outcomes of the methodology. The extra costs depend on the hypothesised regulatory and market frameworks, while the possible harmful impacts on the distribution network operation depend on the defined location of the DERs along the network lines. Thus, for obtaining general validity results, different scenarios of DER location should be simulated to assess the expected maximum and minimum feasible flexibility.