The design of mechanical enclosures is evolving to be more compact and quieter and this compromises the cooling of the internal components. Computational Fluid Dynamics (CFD) based optimization could significantly improve the cooling efficiency of the critical parts of the components to ensure their performance and reliability. This work presents the CFD surrogate based optimization of the forced cooling of two reciprocating compressors located in an enclosure from a gas generator. Due to the challenging project time constraints, the accuracy of the results was compromised to make optimization feasible. The parameters to be optimized were related to the position of the compressors and the cooling fans. The boundary conditions associated to the cooling of the critical parts were derived by experimental data. Artificial Neural Networks (ANNs) were used to construct a surrogate model of the computational model to reduce the time and resources required. The combination of the ANN model with a multi start-gradient based algorithm optimized the position of compressors and cooling fans to minimize the average temperature on the critical parts. A set of new enclosure designs were found with outstanding CFD based performance compared with the design elaborated by engineering intuition.