Optimization Problems at Thermal Equilibrium