## 4 Results and Validation
### Use Case Description
LEM's main goal is to optimize the DA scheduling by minimizing its operating costs. Batteries' charging and discharging are among the decision variables of the optimization problem. The minimization of LEM's operating cost is calculated based on the forecasted values of local generation and local demand in a one-day horizon. The forecasting error, especially in low-scale energy deployments [41], leads to deviations in the output of the optimization problem. Hence, the DAM schedule differs from the optimal deterministicsolution, leading to remedial actions that bear down higher costs on LEM participants. Incorporating stochastic variables in the optimization problem is the key to ensuring a constant, reliable power supply and achieving a cost-efficient LEM operation. The stochasticity of DERs generation and local consumption affects the LEM scheduling [42]. It is crucial to design a market that effectively deals with stochasticity, as the cost for remedial actions will be significant in the case of high uncertainty levels [43]. A wide variety of stochastic optimization methods have been employed to cope with uncertainty in power systems operation, namely scenario-based approaches, robust optimization, and chance-constrained optimization [44]. The chance-constraints method allows certain unexpected events to violate specific constraints considering the overall constraint satisfaction is satisfied with a predefined level of probability. Chance constraints are transformed into deterministic equivalents, and a standard solution method is then employed to solve the problem. The uncertainty of DERs and demand is incorporated into the optimal scheduling process by using statistical moments of the parameters' distribution, which are derived from historical data such as mean and standard deviation [45]. The ability to accommodate a wide range of distributions eliminates the need for discretization of a probability space for scenario sampling [46] or the derivation of a finite uncertainty set [47]. In this work, a chance-constraints approach for the DA scheduling is employed, which explicitly incorporates the stochasticity of DERs generation and local demand and analyzes the effect of uncertainty level on LEM's social welfare. The rationale behind our choice was that compared to the other two stochastic optimization methods, the chance-constrained leads to less conservative results [48]. Another important factor is that the level of uncertainty can be tuned via a confidence interval [49]. Finally, by incorporating the stochastic optimization problem into a chance constraints formulation, the convexity of the optimization problem is maintained. In this paper, stochasticity is accounted for on both the supply (i.e., solar PV) and demand sides. The granularity of the optimal scheduling of the LEM is equal to 1 h and has an interval horizon of 24 h, similar to the wholesale DAM  
Figure 6: LEM pricing curves with feed-out and feed-in tariffs as limits. market architecture. The objective function of the optimization problem is formulated as follows:  
\[\min C_{total}=\sum_{i=1}^{24}(\pi_{int}^{i}\times P_{int}^{i}+\pi_{buy}^{i} \times P_{in}^{i}-\pi_{sell}^{i}\times P_{out}^{i}) \tag{2}\]  
where \(i\), \(l\), \(k\), and \(n\) indicate the hour, flexible consumers, PV owners and battery owners, respectively. \(C_{total}^{i}\) denotes the total LEM cost, \(\pi_{int}^{i}\) is the LEM price, and \(\pi_{buy}^{i}\) and \(\pi_{sell}^{i}\) are the respective feed in and feed out grid tariffs. \(P_{in}^{i}\) and \(P_{out}^{i}\) denote power import and export from and to the grid.