How Well Does the Metropolis Algorithm Cope With Local Optima?