Using numpy, I have this definition of a function:
def powellBadlyScaled(X):
f1 = 10**4 * X[0] * X[1] - 1
f2 = numpy.exp(-numpy.float(X[0])) + numpy.exp(-numpy.float(X[1])) - 1.0001
return f1 + f2
This function is evaluated a huge number of times on an optimization routine. It often raises exception:
RuntimeWarning: overflow encountered in exp
I understand that operand cannot be stored in allocated space for a float. But how can I overcome the problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…