working solver with simulated annealing