## 3 The Proposed Hierarchical Two-Stage Robust DES Planning Model
### Solution Procedure Based on the N-C&CG Algorithm  
The proposed two-stage robust DES planning model is an NP-hard problem, which cannot be solved directly by the commercial solver. According to the C&CG algorithm proposed in [35], the two-stage robust optimization can be divided into the master problem (MP) and subproblem (SP). The MP is a MILP problem and SP is a bi-level LP that can be directly calculated by solvers after being transformed by the KKT conditions. However, in the proposed two-stage robust planning model, binary variables are introduced to the SP by formulas (19) and (20), which resulted in the KKT condition not being applicable. Therefore, an N-C&CG algorithm proposed in [36] is adopted in this paper to handle this problem. According to the N-C&CG algorithm, the proposed two-stage robust planning model as (5)-(25) can be decomposed into the MP, the master problem of SP (MP\({}_{\text{S}}\)), and the subproblem of the SP (SP\({}_{\text{S}}\)) as (26)-(28). Specifically, MP and SP\({}_{\text{S}}\) are MILP problems and MP\({}_{\text{S}}\) is a max-min bi-level LP, which can be transformed into a single-level max MILP problem. \[\begin{array}{c}(\text{\bf MP})\min_{\mathbf{X}}a^{\intercal}\mathbf{X}+\eta\\ \mathbf{AX}\leq d\\ s.t.\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,  
**Second level: Two-stage robust energy storage planning model**  
**Outer loop: Solution of the MP**  
Initialize the loop parameters and initial values of uncertain variables:  
_Step 1_  
\[r=1,UB^{out}=+\infty,LB^{out}=+\infty,\ \boldsymbol{u}^{*}=\boldsymbol{u}^{\boldsymbol{ \theta}}\]  
_Step 2_  
Solve the MP, get the DES capacities \(\boldsymbol{X}^{**}\)=\(\boldsymbol{X}\), and refresh \(LB^{out}=max\Big{\{}LB^{out},\boldsymbol{a}^{T}\boldsymbol{X}^{*}+\eta\Big{\}}\). _Step 3_  
Skip to _Step 1_ in the inner loop, refresh \(\boldsymbol{u}^{**}=\boldsymbol{u}^{**}\). Determine whether the convergence condition is met:  
\[ \begin{array}{ll}\text{(1)}&\text{If }1-LB^{out}/UB^{out}<\epsilon\ (\epsilon\text{ is the convergence threshold), terminate the second level, output the planning result }\boldsymbol{X}^{**}\)=\(\boldsymbol{X}^{**}\) and \(d_{i,i}^{DRu*}=d_{i,i}^{DRf}\) to the first level.  
_Step 4_  
If \(1-LB^{out}/UB^{out}\geq\epsilon\), \(r=r+1\), back to _Step 2_ in the outer loop and add the following constraints to MP.  
\[\begin{cases}\eta\geq\boldsymbol{b}^{T}\boldsymbol{Y}\\ \boldsymbol{B_{1}X}+\boldsymbol{C_{1}Y}^{*}+\boldsymbol{D_{1}Z}^{*}+\boldsymbol {E_{1}u}^{**}\leq\boldsymbol{\epsilon}\\ \boldsymbol{B_{2}X}+\boldsymbol{C_{2}Y}^{*}+\boldsymbol{D_{2}Z}^{*}+ \boldsymbol{E_{2}u}^{**}=f\end{cases}\end{array}  \tag{29}\]  
**Inner loop: Solve the SP**  
Initialize the loop parameters and obtain initial values of binary variables:  
_Step 1_  
\[v=1,UB^{in}=+\infty,LB^{in}=+\infty,\ \boldsymbol{Z}^{**}=\boldsymbol{Z}^{ \prime}\]  
_Step 2_  
Solve the MP\({}_{5}\), refresh \(\boldsymbol{u}^{**}\)=\(\boldsymbol{u}^{\boldsymbol{v}}\) and \(UB^{in}=min\Big{\{}UB^{in},\tau\Big{\}}\). _Step 3_  
Solve the SP\({}_{5}\), refresh \(\boldsymbol{Z}^{**}\)=\(\boldsymbol{Z}^{\prime}\) and \(LB^{in}=max\Big{\{}LB^{in},\boldsymbol{b}^{T}\boldsymbol{Y}^{\circ}\Big{\}}\). Determine whether the convergence condition is met:  
\[\begin{array}{ll}\text{(1)}&\text{If }1-LB^{in}/UB^{in}<\epsilon,\text{ terminate the inner loop, return }\boldsymbol{u}^{**}=\boldsymbol{u}^{**}\) and \(UB^{out}=UB^{in}\) to the outer loop. _Step 4_  
\[