  We consider the problem of finding the energy minimum of a complex quantum
Hamiltonian by employing a non-Markovian bath prepared in a low energy state.
The energy minimization problem is thus turned into a thermodynamic cooling
protocol in which we repeatedly put the system of interest in contact with a
colder auxiliary system. By tuning the internal parameters of the bath, we show
that the optimal cooling is obtained in a regime where the bath exhibits a
quantum phase transition in the thermodynamic limit. This result highlights the
importance of collective effects in thermodynamic devices. We furthermore
introduce a two-step protocol that combines the interaction with the bath with
a measure of its energy. While this protocol does not destroy coherence in the
system of interest, we show that it can further enhance the cooling effect.
