Implemented simulated annealing and changed coefficient calculation function