billsioros/pytsp

Math range error in Annealing

Filarius opened this issue · 0 comments

return exp((current_cost - candidate_cost) / temperature)

 def acceptance_probability(self, current_cost, candidate_cost, temperature):
        if candidate_cost < current_cost:
            return 1
        else:
            return exp((current_cost - candidate_cost) / temperature)

here at exponent calculation I got error
OverflowError: math range error

current_cost = 8348 
candidate_cost = 8616 
temperature = 99937.5

Possible fix - use another "exp" function, numpy.exp as example