## 1 Introduction
Indeed, many uncertainties characterize this future scenario like the actual response of many private resources (consumers and producers) to service requests from the DSO, the organization of the local ancillary services market (if any), and the prices of the new services. Therefore, it is plausible that DSOs wish to start this revolution gradually by introducing solutions that can help limiting the risk associated to this flexibility. Even if not yet exploited, one option available in the current European regulation can be the installation of storage devices directly operated by the DSO. It represents a particular network investment which can be used for many applications simultaneously (losses reduction, peak shaving, voltage regulation) and, in this case, it can increase the flexibility of the secondary substation where it is installed, reducing at the same time the uncertainty of this flexibility exploitation. Following these considerations, ad hoc risk-based tools must be developed for the optimal expansion planning of distribution systems, able to assess the overall technical constraints violation risk of a given network and the residual risks associated to different planning solutions. The first kind of assessment has been formalized in [10] and a possible implementation, proposed by the authors in previous research [12; 13; 14], has been briefly described in Section 3. The second calculation, coupled to the optimal exploitation of flexibility services from DERs, is deeply illustrated in Section 4 and constitutes the main novelty of the paper. This procedure is based on a Robust Linear Programming (RLP) for modelling the uncertainties related to the active management of DER and estimating the residual risk associated to each optimal solution identified. Two type of uncertainties have been considered: the forecast errors of some data entry (the prices for remunerating the flexibility services) and the actual DERs response to a flexibility request from the DSO. Robust Optimization (RO) is a complementary methodology to traditional Sensitivity Analysis and Stochastic Optimization to deal with uncertainties that affect the data of real-world optimization problems. The success of this approach comes from the not required distribution assumptions on uncertain parameters and the computational tractability of the robust formulation of Linear Programming problems [15]. For these reasons,in the last decade RO has been applied to several optimization fields, including power systems. Regarding DERs, RO has been often used to model the uncertain behaviour of load consumption and RES production within specific problems: the optimal energy storage system location [16], the optimal demand bidding under uncertain market and including distribution network operational limits [17], the generation and transmission expansion planning problem [18]. When dealing with the flexibility provided by DERs, RO has been applied from the aggregator point of view for maximizing the flexibility potential of its customers to provide services to other actors [19] and to minimize day-ahead operation costs while complying with energy commitments in the day-ahead market and local flexibility requests [20]. To the best of authors' knowledge, RO has not been yet applied from the DSO point of view to model the uncertain provision of flexibility services used for distribution network planning. In summary, the present work proposes a RLP for the minimization of the procurement costs of flexibility services from DERs used to solve possible technical issues in the distribution network. The tool is ready for the integration in a wider risk-based planning tool for SDN. Particular attention has been paid to the assessment of the residual risk of the optimal solution, due to the uncertain provision of flexibility services. The objective function of the RLP implements an economic model of the flexibility services remuneration, based on capacity and energy terms.