# Energy Optimization in Hotels: Strategies for Efficiency in Hot Water Systems
## 3 Materials and Methods
### Energy Optimization Procedure
#### 3.3.1 Target Function  
The proposed objective function seeks to minimize the energy consumed by guaranteeing the minimum temperature difference between the heat recovery temperature (\(T_{\mathrm{gc}}\)) and the auxiliary heating temperature (\(T_{\mathrm{ca}}\)); see Equation (1). \[FO=\min\sum_{k=0}^{24}Q_{\mathrm{ca}}=m_{\mathrm{cp}}\cdot C_{p}\big{[}T_{ \mathrm{ca}}(k)-T_{\mathrm{gc}}(k)\big{]} \tag{1}\]  
The decision variables are defined as those that can be operationally modified:  
* \(m_{cp}\): hot water flow in the primary circuit, kg/s;
* \(m_{cs}\): hot water flow in the secondary circuit, kg/s;
* \(T_{ca}\): temperature at the outlet of the auxiliary heater, \({}^{\circ}\)C;
* \(T_{\mathrm{gc}}\): the heat recovery temperature, \({}^{\circ}\)C.  
Figure 4: Average monthly LPG consumption of the case study hotel. The expression describing the behavior of the supply temperature as a function of the independent variables is given by Equation (2):  
\[T_{\text{sum}}=\frac{m_{\text{cp}}}{m_{\text{cs}}}(T_{\text{ca}}-T_{6})+\left( \frac{m_{\text{ret}}+m_{\text{cs}}}{m_{\text{ret}}+m_{\text{rep}}}\right)T_{k}+ \left(\frac{m_{\text{rep}}}{m_{\text{ret}}+m_{\text{rep}}}\right)T_{\text{rep}} \tag{2}\]  
where  
* \(T_{\text{sum}}\): hot water supply temperature, \({}^{\circ}\)C;
* \(T_{k}\): temperature of the storage tanks, \({}^{\circ}\)C;
* \(T_{\text{rep}}\): temperature of the replenishment water, \({}^{\circ}\)C;
* \(T_{6}\): water temperature at heat recovery, \({}^{\circ}\)C;
* \(m_{\text{ret}}\): return water flow, kg/s;
* \(m_{\text{rep}}\): replenishment water flow, kg/s. Optimization with Genetic Algorithms  
Energy systems with fluctuating demand, such as domestic hot water systems in hotels, require adaptive optimization methods to balance efficiency, cost, and stability. In this context, GA emerge as an effective tool due to their ability to solve complex problems by simulating natural selection. GA are particularly suitable for multi-objective problems, where their ability to explore multiple solutions simultaneously is valuable. Their structure, based on evolutionary principles, allows them to adapt effectively to problems with nonlinear constraints and interdependent variables. In addition, they are often more robust than other optimization methods in scenarios with multiple local optima and complex constraints, making them ideal for dynamic energy systems. In practice, GA offer balanced solutions between sustainability, efficiency, and operational resilience, making them a versatile tool for optimizing energy systems with variable demand [27]. GA are implemented as an optimization tool to minimize the costs of domestic hot water (DHW) production in the facility. This approach considers the operating constraints inherent to the system model. GA, recognized for their ease of implementation and computational efficiency, offer a robust solution for complex problems involving the management of operational variables in thermal systems, especially those subject to variable demand. The optimization procedure following the GA approach is as follows (Figure 5):  
Main Program  
1. Initial configurations
* Read data from a set of measurements taken every 10 min, stored in the file Datos.mat. These include:
* Total Power (Ptotal)
* Inlet water temperature to the heat recovery system (T6)
* Chilled water temperature (Tah)
* Ambient temperature (Tamb)
* Sanitary water return flow (mRet)
* Sanitary water supply flow (mSum)
* Time vector (tiempo)
2. Calculate cooling load (\(Q_{ch}\)) for each compressor using the equation \[Q_{ch}=A_{1}+A_{2}\cdot P_{\text{total}}+A_{3}\cdot T_{\text{amb}}+A_{4}\cdot T _{\text{ah}}+A_{5}\cdot P_{\text{total}}\cdot T_{\text{ah}}+A_{6}\cdot T_{ \text{ah}}\cdot T_{\text{amb}}\]3. Calculate total condensation heat (\(Q_{\text{cond}}\)) for each compressor: \[Q_{\text{cond}}=P_{\text{total}}\cdot Q_{ch}\]
4. Define chiller operating parameters and calculate recovered heat in the cycle: \[Q_{\text{rec}}=m_{r}\cdot C_{p}\cdot(T_{2}-T_{\text{cond}})\]
5.