Relatively new to Python and struggling with a compatibility issue. Originally developed some code in 3.6 on my desktop but need to run it on a server which has 2.7 (and I can't upgrade the server - it's complicated!). The code runs on each platform with no errors. However, it runs correctly in 3.6 and the results in 2.7 are completely off. The problem seems to be in the scipy.optimize - the minimize function. In 3.6, the minimize function converges on a minimum and returns the expected result. In 2.7, the exact same code and inputs, it is clear that the minimize function does not converge and ultimately uses the upper bounds. That causes the returned results to be completely unrealistic. I am assuming that this is a syntax issue between 3.6 and 2.7, but with repeated searches, I have yet to find anything that points to the potential problem. Below is my minimize function:
from scipy.optimize import minimize
...
##############################################################################
#Minimize function
##############################################################################
def optimize(beta, eta, ht, age_day, age):
initial_guess = [beta, eta]
global cur_clust
result = minimize(Renewal, initial_guess, args=[ht,age_day,age],method = 'SLSQP', bounds=((0.4,8.0),(0.05,1000.0)),options = {'disp': False})
if result.success:
fitted_params = result.x
#print(cur_clust)
#print(fitted_params)
B_opt = fitted_params[0]
E_opt = fitted_params[1]
SSE = result.fun
else:
B_opt = 9999
E_opt = 9999
SSE = result.fun
return B_opt, E_opt, SSE;
Any suggestions?
Thanks!