## 3 Problem Formulation
### Constraints  
The objective function is subjected to the following constraints.  
(1) The electrical, heating and cooling energy balance are expressed as follows:  
\[P^{\text{Grid}}(t)+P^{PV}(t)+P_{E}^{CHP}(t)+P_{B,dis}(t)= P_{E}^{EC}(t)+P_{E}^{EHP}(t)+P_{B,ch}(t)+P_{E}^{D^{\prime}}(t) \tag{16}\] \[P_{H}^{CHP}(t)+P_{H}^{GB}(t)+P_{H}^{EHP}(t)+P_{H,dis}(t)= P_{H}^{AC}(t)+P_{H,ch}(t)+P_{H}^{D^{\prime}}(t)\] (17) \[P_{C}^{EC}(t)+P_{C}^{AC}(t)+P_{C,dis}(t)= P_{C,ch}(t)+P_{C}^{D^{\prime}}(t) \tag{18}\]  
(2) The energy conversion facilities' power limitations are expressed as follows:  
\[0\leq P^{\text{CHP}}(t)\leq P_{Max}^{\text{CHP}} \tag{19}\]  
\[0\leq P^{\text{GB}}(t)\leq P_{Max}^{\text{GB}} \tag{20}\]  
\[0\leq P^{\text{EHP}}(t)\leq P_{Max}^{\text{EHP}} \tag{21}\]  
\[0\leq P^{\text{EC}}(t)\leq P_{Max}^{\text{EC}} \tag{22}\]  
\[0\leq P^{\text{AC}}(t)\leq P_{Max}^{\text{AC}} \tag{23}\]  
\[0\leq P^{\text{PV}}(t)\leq P_{Max}^{\text{PV}} \tag{24}\]  
where \(P_{Max}^{\text{CHP}}\), \(P_{Max^{\prime}}^{\text{GB}}\), \(P_{Max^{\prime}}^{\text{EHP}}\), \(P_{Max^{\prime}}^{\text{EC}}\), \(P_{Max}^{\text{AC}}\) and \(P_{Max}^{\text{PV}}\) stand for the maximum output power limits for the CHP, gas boiler, electrical heat pump, electric chiller, absorption chiller and PV, respectively.  
(3) The technical constraints of the HESThe operational constraints of the battery storage are expressed as  
\[0\leq P_{B,ch}(t)\leq\mu_{B}P_{B,ch}^{\max} \tag{25}\]  
\[0\leq P_{B,dis}(t)\leq(1-\mu_{B})P_{B,dis}^{\max} \tag{26}\]  
\[E_{B}^{\min}\leq E_{B}(t)\leq E_{B}^{\max} \tag{27}\]  
\[E_{B}(T)= E_{B}(0) \tag{28}\]  
Equations (25) and (26) express the minimum and maximum limits of charging/ discharging power for the ES, wherein \(\mu_{B}\) is a binary charging/discharging state. Equation (27) expresses the minimum and maximum energy stored in the ES. Equation (28) expresses that the energy stored in the ES at the end of the considered time horizon must be equal to the initial one.  
The operational constraints of the HS/CS are expressed as  
\[\mu_{\phi}P_{\phi,ch}^{\min}\leq P_{\phi,ch}(t)\leq\mu_{\phi}P_{\phi,ch}^{\max} \tag{29}\]  
\[(1-\mu_{\phi})P_{\phi,dis}^{\min}\leq P_{\phi,dis}(t)\leq(1-\mu_{\phi})P_{\phi,dis}^{\max} \tag{30}\]  
\[E_{\phi}^{\min}\leq E_{\phi}(t)\leq E_{\phi}^{\max} \tag{31}\]  
\[E_{\phi}\Big{(}T)= E_{\phi}(0) \tag{32}\]  
Equations (29) and (30) express the minimum and maximum limits of charging/ discharging power for the HS and CS, respectively, wherein \(\mu_{\phi}\) is a binary charging/ discharging state. Equation (31) expresses the upper and lower bounds of the stored heating/cooling energy in the HS/CS. Equation (32) denotes that the energy stored in the HS/CS at the end of the considered time horizon must be equal to the initial one.  
(4) The input natural gas and electricity limitations are described by:  
\[P^{\rm Gas}\Big{(}t)= P_{CHP}^{\rm Gas}(t)+P_{GB}^{\rm Gas}(t) \tag{33}\]  
\[0\leq P^{\rm Gas}(t)\leq P_{Max}^{\rm Gas} \tag{34}\]  
\[0\leq P^{\rm Grid}(t)\leq P_{Max}^{\rm Grid} \tag{35}\]  
where \(P_{CHP}^{\rm Gas}\) and \(P_{GB}^{\rm Gas}\) represent the gas consumed by the CHP and GB, respectively. Equation (34) describes that the scheduled gas cannot exceed the maximum pipeline capacity. Equation (35) describes that the scheduled electrical power cannot exceed the maximum capacity of the tie-line between the MEMG and utility grid.  
Further, the model of IDR includes Equations (13) and (14).