## Methodology
### Optimization Problem and Method  
The objective function to be minimized is the Equivalent Annual Cost (EAC) of the system, which is calculated over the period of a year and composed of the annualized investment cost for the technologies, _Invest_, and the total annual operating cost, \(Op\). \[EAC:f=\textit{Invest}+Op \tag{12}\]  
\[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]  
where \(CAP_{i}\) is the capacity of the \(i\)th technology to be installed (expressed in kW), \(a_{i}\) and \(b_{i}\) are the correlation parameters of the equipment cost as a function of the capacity, and \(CRF\) is the capital-recovery factor. \[CRF=\frac{r(r+1)^{lifetime}}{(r+1)^{lifetime}-1} \tag{14}\]  
The total annual operating cost comprises the cost for purchasing electricity and natural gas and the revenue from selling electricity to the grid. An hourly timestep has been considered. \[Op=\sum_{t=1}^{8760}[c_{F}[F_{ICE,t}+F_{B,t}]+c_{PE}E_{P,t}-c_{SE}E_{S,t}] \tag{15}\]  
Demand constraints must be satisfied in each \(t\) th time step. \[E_{ICE,t}+E_{PV,t}+E_{WT,t}+E_{P,t}-E_{S,t}-E_{EC/RHP-C,\ t}-E_{RHP-H,t}-E_{CT,t }=E_{D,t} \tag{16}\]  
\[Q_{ICE,t}+Q_{B/RHP-H,t}\geq Q_{D,t} \tag{17}\]  
\[C_{AC,t}+C_{EC/RHP-C,t}\geq 0 \tag{18}\]  
where \(t=1,2,\dots,\ 8760\), and the electric consumption due to the cooling-tower fans depends on the amount of heat to be rejected from the absorption chiller:  
\[E_{CT,t}=C_{AC,t}\frac{(1+COP_{AC,t})}{COP_{AC,t}}\varepsilon_{CT} \tag{19}\]  
Governing equations and capacity constraints must also be considered:  
\[E_{ICE,t}\leq E_{ICE,nom}\delta_{ICE,t} \tag{20}\]  
\[E_{ICE,t}\geq E_{ICE,min}\delta_{ICE,t} \tag{21}\]\[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]0 \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]1 (23) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]2 (24) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]3 (25) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]4 (26) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]5 (27) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]6 (28) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]7 (29) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]8 (30) \[\textit{Invest}=\sum_{i}a_{i}CAP_{i}^{b_{i}}CRF_{i} \tag{13}\]9 (31) \[CRF=\frac{r(r+1)^{lifetime}}{(r+1)^{lifetime}-1} \tag{14}\]0 (32) \[CRF=\frac{r(r+1)^{lifetime}}{(r+1)^{lifetime}-1} \tag{14}\]1  
where \(t=1,2,\ldots,\ 8760\). Ultimately, the overall problem consists in the minimization of the Equivalent Annual Cost:  
\[CRF=\frac{r(r+1)^{lifetime}}{(r+1)^{lifetime}-1} \tag{14}\]2  
which results in a mixed integer non-linear optimization problem. To solve this optimization problem, a two-stage algorithm has been specifically developed, which is schematically summarized in \[CRF=\frac{r(r+1)^{lifetime}}{(r+1)^{lifetime}-1} \tag{14}\]3 The optimization variables can be distinguished in two main groups: sizing variables (i.e., \(E_{ICE,nom},\ Q_{B,nom},C_{EC,nom},Q_{RHP-H,nom},E_{PV},E_{WT}\)) and operation variables (i.e., \(E_{ICE,t}\), \(C_{EC/RHP-C,t}\), \(Q_{R/RHP-H,t}\), \(E_{S,t}\), \(E_{P,t}\), \(C_{AC,t}\) with \(t=1,\ldots,8760\)). Therefore, the problem can be decomposed into two levels: the upper level, where the optimal capacity of each energy unit is identified, and the lower level, where the optimal operating conditions of the system in each timestep are found. Obviously, the two problems must be solved simultaneously. At the upper level, the sizing problem is addressed by means of a Genetic Algorithm, which is a widely used optimization tool for the design of DESs [33]. Clearly, it is also possible that in the optimal solution a technology is not included in the system, i.e., its resulting optimal size is null. At the lower level, since the operation problem under analysis is static, it can be solved by means of a \"greedy approach\" [18; 34].