python code of simulated annealing