## 2 MILP Model
### Energy Balances  
Energy balances are a set of constraints which ensure that in each node and in each time interval the input energy is equal to the output energy. With reference to the superstructure represented in Figure 1, there are nodes three for each site (electric, thermal and cooling) plus the two nodes of the central site (electric and thermal). The energy balance of the network is included in the node energy balance. In the following the electric balance for a site \(u\) is described in detail, while the thermal and cooling balances are reported with no description.  
The electricity and the thermal balances of a site are expressed by:  
\[\begin{split}\textbf{E}_{\textit{ice}}(m,d,h,u)+\textbf{E}_{ \textit{mgt}}(m,d,h,u)+\textbf{E}_{\textit{prop}}(m,d,h,u)+\textbf{E}_{\textit{ bgt}}(m,d,h,u)=\textbf{E}_{\textit{cc}}(m,d,h,u)\\ +\textbf{E}_{\textit{lip}}(m,d,h,u)+\textbf{E}_{\textit{dem}}(m,d,h,u)+\textbf{E}_{\textit{sol}}(m,d,h,u)\end{split} \tag{37}\]  
\[\begin{split} H_{\textit{mgt}}(m,d,h,u)+H_{\textit{icc}}(m,d,h,u )+H_{\textit{stp}}(m,d,h,u)+\textbf{H}_{\textit{boi}}(m,d,h,u)+H_{\textit{ lfp}}(m,d,h,u)\\ +\textbf{H}_{\textit{net}}(m,d,h,v,u)(-1-p_{t}(v,u))=\textbf{H}_{ \textit{ts}}(m,d,h,u)+H_{\textit{abs}}(m,d,h,u)+H_{\textit{dem}}(m,d,h,u)+ \textbf{H}_{\textit{net}}(m,d,h,u,v)\end{split} \tag{38}\]  
The thermal energy to be stored can be produced only by ICE, MGT and ST panels:  
\[H_{\textit{mgt}}(m,d,h,u)+H_{\textit{icc}}(m,d,h,u)+H_{\textit{stp}}(m,d,h,u )-\textbf{H}_{\textit{ts}}(m,d,h,u)\geq 0 \tag{39}\]  
The cooling balance of a site is expressed by:  
\[\textbf{C}_{\textit{abs}}(m,d,h,u)+\textbf{C}_{\textit{cc}}(m,d,h,u)+\textbf{ C}_{\textit{lip}}(m,d,h,u)=\textbf{C}_{\textit{dem}}(m,d,h,u)+\textbf{C}_{ \textit{ts}}(m,d,h,u) \tag{40}\]  
The cooling energy to be stored can be produced only by CC, ABS and HP:  
\[\textbf{C}_{\textit{abs}}(m,d,h,u)+\textbf{C}_{\textit{cc}}(m,d,h,u)+\textbf{ C}_{\textit{lp}}(m,d,h,u)-\textbf{C}_{\textit{ts}}(m,d,h,u)\geq 0 \tag{41}\]As far as the central unit is concerned, the electricity produced by the central CHP can only be sold, while the thermal balance is expressed by:  
\[H_{ice,c}(m,d,h)+\mathbf{H_{boi,c}}(m,d,h)+H_{stp,c}(m,d,h)=\mathbf{H_{net,c}}(m,d,h)+ \mathbf{H_{ts,c}}(m,d,h) \tag{42}\]  
The thermal production of the central unit can be shared among the users, which receive heat from the DHN through node \(u\). Therefore, the thermal balance related to the central unit site reads:  
\[\begin{split}& H_{mgt}(m,d,h,u)+H_{icc}(m,d,h,u)+H_{stp}(m,d,h,u)+H_{ bait}(m,d,h,u)+H_{hp}(m,d,h,u)+H_{net}(m,d,h,v)(1-p_{t}\left(v,u\right)\\ &\qquad+\mathbf{H_{net,c}}(m,d,h)(1-p_{t,c})=\mathbf{H_{hs}}(m,d,h,u)+H_{ abs}(m,d,h,u)+H_{dam}(m,d,h,u)+\mathbf{H_{net}}(m,d,h,u)+\mathbf{H_{net}}(m,d,h,v) \end{split} \tag{43}\]  
All continuous variables have to be greater than zero, except the variables related to the thermal storage input/output heat flow (\(\mathbf{H_{ts,c}}\), \(\mathbf{H_{ts}}\), \(\mathbf{C_{ts}}\)) which are free. Positive values represent input flows, while negative values mean an energy extraction from the thermal storage. The temperatures of the thermal flows are not taken into account because it would have compromised the linearity of the problem. However, this is not a strong approximation considering that the thermal energy required by the users is normally supplied at a temperature of 50-55 \({}^{\circ}\)C and all components are able to produce the thermal energy at higher temperatures. Some restrictions due to the coupling of components related to the operating temperatures (ICE, MGT together with ABS) have been considered through a particular conformation of the superstructure and with additional constraints which consider this matter (e.g., Equations (17) and (18)).