## 2 System Model
### Optimization Objectives  
The objectives of the energy management for the resilient microgrid studied in this paper are to reduce the operational costs of the system and its dependence on the main grid. Based on the generation from renewable sources such as wind and photovoltaics, load usage, and electricity price information, the system aims to reduce costs by charging during low electricity price periods and discharging during high electricity price periods using the energy storage system. Through coordinated control of generation equipment, energy storage, and loads, the system also aims to decrease its reliance on the main grid. This approach has several benefits, including mitigating the impact of renewable energy fluctuations on the main grid, increasing the utilization of renewable energy, and enhancing the reliability of the microgrid system. It is suitable for energy management in extreme environments like islands, border regions, and military bases. Therefore, the optimization objective of the microgrid consists of two parts: minimizing the operational costs of the system and minimizing the energy exchange between the microgrid and the main grid. The calculation of operational costs is as follows:  
\[C_{1}=\min\sum_{k=1}^{T}\left[C_{DG}(k)+C_{bess}(k)+C_{\text{cur}}\left(k \right)+C_{\text{grid}}\left(k\right)\right] \tag{14}\]  
where \(C_{DG}(k),C_{BESS}(k),C_{\text{cur}}(k)\), and \(C_{\text{grid}}(k)\) represent the operating costs of the diesel generator and the energy storage system at time \(k\), the penalty for load shedding, and the cost of buying and selling electricity, respectively. The operating cost of the diesel generator includes fuel cost, startup cost, and maintenance cost, and is calculated as follows:  
\[C_{DG}(k)=C_{fuel}(k)+OM_{DG}\cdot\delta_{DG}(k)\cdot\Delta t+\chi_{DG}^{up}(k )+\chi_{DG}^{down}(k) \tag{15}\]where \(C_{fuel}(k)\) is the fuel cost for the diesel generator at time \(k\), \(OM_{DG}\) is the maintenance cost per unit time of generator operation, \(\delta_{DG}(k)\) represents the operational state of the diesel generator at time \(k\) (1 for on, 0 for off), and \(\chi_{DG}^{up}(k)\) and \(\chi_{DG}^{down}(k)\) represent the fixed costs for each startup and shutdown. The fuel cost \(C_{fuel}(k)\) for the diesel generator at time \(k\) is calculated as:  
\[C_{fuel}(k)=\left(aP_{DG}^{2}(k)+bP_{DG}(k)+c_{i}\right)\cdot\Delta t \tag{16}\]  
where \(a\) and \(b\) represent the first and second-order constant coefficients of fuel cost, \(P_{DG}\) is the power output of the diesel generator at time \(k\), and \(\Delta t\) is the time granularity, which is 1 hour in this case. The operating cost of the energy storage system includes maintenance costs and losses from charging and discharging. \[C_{\text{bess}}\left(k\right)=\left|P_{\text{bess}}\left(k\right)\right|OM_{ \text{bess}}\,\Delta t+c_{\text{bess}}^{switch}(\delta_{\text{bess}}\left(k \right)-\delta_{\text{bess}}\left(k-1\right))^{2} \tag{17}\]  
where \(OM_{BESS}\) represents the maintenance cost per unit time for the energy storage system, and \(c_{BESS}^{switch}\) represents the cost associated with charging and discharging losses. The penalty cost for load shedding is calculated based on the penalty coefficient \(\alpha_{cur,i}(k)\) and the power of the shed load \(\beta_{cur,i}(k)P_{cur,i}(k)\):  
\[C_{cur}(k)=\alpha_{cur,i}(k)\beta_{cur,i}(k)P_{cur,i}(k)\cdot\Delta t \tag{18}\]  
The cost of buying and selling electricity is determined by the interaction power between the microgrid and the main grid \(P_{grid}(k)\) and the electricity price. \[ \begin{split}\eta_{grid}(k)=\left\{\begin{array}{cc}c_{grid}^{ bar}(k)&P_{grid}(k)>0\\ \xi_{grid}^{\text{sel}}\left(k\right)&P_{grid}(k)\leq 0\\ \end{array}\right.\\ C_{grid}(k)=\eta_{grid}(k)P_{grid}(k)\Delta t\end{split}  \tag{19}\]  
where \(P_{grid}(k)>0\) represents that the microgrid's generation capacity is insufficient to meet the total demand, and it needs to purchase electricity from the main grid.