## 2 MILP Model
### Thermal Storage  
A long-term thermal storage might be able to extend the operation time of the combined heat and power (CHP) unit. In fact, during summer time, for instance, the heat demand can be so low that the CHP plant must be shut down and a boiler, which is often expensive in terms of operational cost, must be brought into operation. By using a thermal storage, power generation can be increased and the use of fossil fuels can be reduced [29]. The problem of intermittent energy sources is especially severe for solar energy, because thermal energy is usually needed most when solar availability is lowest, namely, in winter. Small TS can cover periods of inadequate sunshine, while large TS, operating over long period, can partially cover the lower winter solar thermal production [30]. In any case, the design of the integrated system is very difficult and normally several rules of thumb are used to define the system. An optimization procedure can be very helpful to reach a full exploitation of the potential benefit of CHP and solar systems. The thermal and cooling storages which can be installed in each production unit or in the central unit can be modelled in the same way, accepting the approximations of perfect stratification of medium (water) inside the thermal storage. This approximation correspond to the hypothesis that, if the storage is not completely discharged, the residual energy is stored at the same temperature required by the DHN. The energy stored in the thermal energy storage, can be evaluated through:  
\[\mathbf{Q_{ts}}=\mathbf{V_{ts}}\cdot p_{p}\cdot c_{p}\cdot\Delta t \tag{33}\]  
As well as for the DHCN, the temperature difference \(\Delta t\) between inlet and outlet temperature is considered constant. Therefore, the thermal energy stored in the thermal storage is proportional to the volume of the medium inside the storage and it is considered as a decision variable. A set of equations is required to describe the energy balance of the thermal storage. In order to allow for the seasonal charging/discharging cycle, the thermal storage has to be modelled throughout the whole year, without any time decomposition as can be done for the other components, where a set of similar days can be represented by only one _typical day_. Applying the typical day approach to all operation variables, except for the variables which represent the energy stored in the thermal storages, allows us,in any case, to reduce the overall number of variables, keeping the option of properly representing the charge and discharge phases of the thermal storages during all the year. In the proposed model, the year is decomposed into 24 typical days of 24 h, one typical working day and one typical non-working day each month. Therefore, each single month is made up of four similar weeks, in turn made up of five similar working days and two similar non-working days. In this way, the optimal operation of the system is similar in each working or non-working day of the month and each month of the year is made up of 28 days. This approximation can be accepted selecting particular typical days which describe the whole year producing the same total consumption. Specific procedures for the identification of the proper typical days can be found in [31; 32]. The energy balance of the thermal storage is approximated considering that the energy contained in the storage in a general time interval \(t\) is equal to the energy stored in the time interval \(t\)-1 multiplied by a thermal loss coefficient plus the input energy in the time interval \(t\):  
\[\textbf{Q}_{\textit{ts}}(m,s,d,r,h,u)-K_{\textit{loss},\textit{ts}}(u)\cdot \textbf{Q}_{\textit{ts}}(m,s,d,r,h-1,u)=\textbf{H}_{\textit{ts}}(m,d,h,u) \tag{34}\]  
Additional constraints have to be added to connect the storage's condition at the end of a time period with that at the beginning of the following one.