## 3 Problem Formulation
### Lower-Level Model for MG  
The lower-level objective function is intended to maximize the profit of the MGO connected to the DN considering five different terms.  
\[\max\ f=\sum\limits_{t=1}^{T}[Pr_{L}(t)+Pr_{e}(t)+Pr_{m}(t)+Pr_{PV}(t)+Pr_{BESS }(t)] \tag{19}\]where \(Pr_{O}(t)\) is the profit including loads, and exchanged power between DSO and MGO, MT, PV, and BESS, respectively.  
The profit terms of the above objective function are defined as follows:  
\[Pr_{L}(t)=\rho_{e}(t)\sum_{i=1}^{N}P_{Li}(t) \tag{20}\]  
\[Pr_{e}(t)=\rho_{e}(t)\Big{(}P_{tie,p}(t)-P_{tie,s}(t)\Big{)} \tag{21}\]  
\[Pr_{m}(t)=-\sum_{i}^{N}\rho_{mi}P_{Gni}(t) \tag{22}\]  
\[Pr_{PV}(t)=-\sum_{i}^{N}\rho_{PVi}P_{PV}(t) \tag{23}\]  
\[Pr_{BESS}(t)=-\sum_{i}^{N}\rho_{BESSi}\Big{(}P_{B,d}(t)-P_{B,c}(t)\Big{)} \tag{24}\]  
where \(P_{B,c}\) and \(P_{B,d}\) are the battery charge and discharge power, respectively.  
The micro sources in the DN include the WTs, PV panels, and BESS. The models and equations for these micro sources are presented below:  
(1) WTs  
The output power of the WTs is modeled using the following parameters, provided in [27], which can be expressed as  
\[P_{WT}=\begin{cases}0&v\leq v_{ci}\,or\,v\geq v_{\alpha}\\ \varepsilon_{1}\cdot v^{3}-\varepsilon_{2}\cdot P_{rate}&v_{ci}<v\leq v_{r}\\ P_{rate}&v_{r}<v\leq v_{\alpha}\end{cases} \tag{25}\]  
where \(v\) is wind speed; \(v_{ci}\) is the cut-in speed; \(v_{\alpha}\) is the cut-off speed; \(v_{r}\) is the rated speed; \(\varepsilon_{1}\) and \(\varepsilon_{2}\) are the fitting parameters of the WT power curve; \(P_{rate}\) is the rated output power of the WT.  
(2) PV panels  
The PV output power is expressed as a function of the irradiance and temperature. Thus, the PV panels can be modeled as  
\[P_{PV}=P_{STC,\max}\cdot\frac{G_{AC}}{G_{STC}}\cdot(1+k(T_{e}-T_{STC})) \tag{26}\]  
where \(P_{PV}\) is the output power of the PV system; \(P_{STC,\max}\) is the maximum output under standard test conditions; \(G_{AC}\) is the current irradiance; \(G_{STC}\) is the standard irradiance; \(k\) is the temperature coefficient; \(T_{\varepsilon}\) is the current temperature; \(T_{STC}\) is the standard temperature; \(G_{STC}\) = 1000 W/m\({}^{2}\), and \(T_{STC}\) = 25 \({}^{\circ}\)C [28].  
(3) BESS  
The energy storage units are used for energy compensation between the MG supply and demand. The following constraints are considered for the charging and discharging strategy [29]:  
\[S_{Bi,t,\min}\leq S_{Bi,t}\leq S_{Bi,t,\max} \tag{27}\]  
\[S_{Bi,t+1}=S_{Bi,t}+\eta_{c}P_{B,c}(t)\Delta t-P_{B,d}(t)\Delta t/\eta_{d} \tag{28}\]  
where \(\eta_{c}\) and \(\eta_{d}\) are the battery efficiencies during the charging and discharging processes, respectively.  
During the charging and discharging processes, the power should be limited, as follows:  
\[0\leq P_{B,c}(t)\leq P_{B,c,\max} \tag{29}\]  
\[P_{B}(t)=P_{B,c}(t)-P_{B,d}(t) \tag{30}\]  
In our work, we assumed that the energy stored in the batteries during the end scheduling period is greater than \(S_{Bi,base}\), to ensure that the batteries have stored energy available for the next day. This limit can be expressed as  
\[S_{Bi}^{*}\geq S_{Bi,base} \tag{31}\]  
where \(S_{Bi}^{*}\) is the energy of the \(i\)th BESS in the end dispatch period; \(S_{Bi,base}\) is the minimum required dispatched energy of the \(i\)th BESS.  
The power balance equation of the MG can therefore be modified as follows:  
\[\sum_{i=1}^{N_{C}}P_{G_{mi}i}(t)+\sum_{i=1}^{N_{B}}P_{Bi}(t)+\sum_{i=1}^{N_{WT }}P_{WTi}(t)+\sum_{i=1}^{N_{PV}}P_{PVi}(t)+P_{Tie}(t)=P_{load} \tag{32}\]  
The inequality constraint of the MT output limit can be expressed as  
\[P_{G_{mi}i,\min}(t)\leq P_{G_{mi}i}(t)\leq P_{G_{mi,\max}}(t) \tag{33}\]