## 3 Bi-Level Optimal Model of a Distribution Network Comprising a Micro Energy Grid
### Optimal Micro-Energy-Grid Model
#### 3.2.2 Constraint Conditions  
1. Constraints for the cooling-heating-electrical power balance of the micro energy grid \[\left\{ \begin{array}{c}P_{\text{CASHP}}(t)+P_{\text{AC}}(t)+P_{\text{estor}}(t )=P_{\text{coolingload}}(t)\\ P_{\text{HASHP}}(t)+P_{\text{EB}}(t)+P_{\text{GB}}(t)+P_{\text{hstor}}(t)=P_{ \text{heatload}}(t)\\ P_{\text{estor}}(t)+P_{\text{MT}}(t)+P_{\text{exgrid}}(t)+P_{\text{WT}}(t)+P_{ \text{PV}}(t)=P_{\text{electriload}}(t)+P_{\text{ASHP}}(t)\end{array} \right.,\] (11)  
where \(P_{\text{CASHP}}(t)\) is the exchanged cooling power of the air-source heat pump; \(P_{\text{AC}}(t)\) is the cooling power of the lithium-bromide absorption-type refrigerator; \(P_{\text{estor}}(t)\) is the charging or discharging cooling power of the cooling storage tank (the value of discharging cooling power is negative, and the value of charging cooling power is positive); \(P_{\text{coolingload}}(t)\) is the cooling load; \(P_{\text{HASHP}}(t)\) is the exchanged heating power of the air-source heat pump; \(P_{\text{EB}}(t)\) is the heating power of the heat-recovery boiler; \(P_{\text{GB}}(t)\) is the heating power of the gas-fired boiler; \(P_{\text{hstor}}(t)\) is the charging or discharging heating power of the heating storage tank (the value of discharging heating power is negative, and the value of charging heating power is positive); \(P_{\text{heatload}}(t)\) is the heating load; \(P_{\text{estor}}(t)\) is the charging or discharging electrical power of the battery storage (the value of discharging electrical power is negative, and the value of charging electrical power is positive); \(P_{\text{MT}}(t)\) is the electrical power of the microturbine; \(P_{\text{WT}}(t)\) is the electrical power of wind power; \(P_{\text{PV}}(t)\) is the electrical power of PV; \(P_{\text{ASHP}}(t)\) is the electrical power of the air-source heat pump in exchanging cooling or heating power; and \(P_{\text{electriload}}(t)\) is the electrical load. 2. Constraints for battery storage, and the cooling and heating storage tanks  
Battery storage, and heating and cooling storage tanks played the role of peak load shifting in the micro energy grid. Their working principles were similar. Therefore, their general constraints were as follows:  
\[E_{\text{min}}\leq E(t)\leq E_{\text{max}}. \tag{12}\]  
\[E(0)=E(T). \tag{13}\]  
\[P_{\text{stor}}^{t}=\left\{ \begin{array}{c}P_{\text{dis}}^{t},0\leq P_{ \text{dis}}^{t}\leq P_{\text{dma}},P_{\text{stor}}^{t}\geq 0\\ -P_{\text{ch}}^{t},0\leq P_{\text{ch}}^{t}\leq P_{\text{cmax}},P_{\text{stor}}^ {t}<0\end{array} \right., \tag{14}\]  
where \(E(t)\) is the capacity of battery storage, and the heating and cooling storage tanks at time \(t\); \(E_{\text{min}}\) and \(E_{\text{max}}\) are the maximum and minimum capacities of battery storage, and the heating and cooling storage tanks, respectively; and \(P_{\text{cmax}}\) and \(P_{\text{dma}}\) are the maximum charging and discharging powers of battery storage, and the heating and cooling storage tanks, respectively. 3. Exchanged electrical power between the distribution network and the micro energy grid \[P_{\text{exgrid}}^{\text{min}}\leq P_{\text{exgrid}}(t)\leq P_{\text{exgrid }}^{\text{max}},\] (15)  
where \(P_{\text{exgrid}}^{\text{min}}\) and \(P_{\text{exgrid}}^{\text{max}}\) are the minimum and maximum exchanged power between the distribution network and the micro energy grid, respectively. 4. Ramping constraints \[\left\{ \begin{array}{c}-R_{\text{MT}}^{\text{down}}\leq P_{\text{MT}}(t)- P_{\text{MT}}(t-1)\leq R_{\text{MT}}^{\text{up}}\\ -R_{\text{GB}}^{\text{down}}\leq P_{\text{GB}}(t)-P_{\text{GB}}(t-1)\leq R_{ \text{GB}}^{\text{up}}\end{array} \right.,\] (16)  
where \(R_{\text{MT}}^{\text{down}}\) and \(R_{\text{MT}}^{\text{up}}\) are the lower and upper ramp speeds of the microturbine, respectively; and \(R_{\text{GB}}^{\text{down}}\) and \(R_{\text{GB}}^{\text{up}}\) are the lower and upper ramp speeds of the gas-fired boiler, respectively.