implement simulated annealing