added code for simulated annealing.