python - Anomalous constrained scipy.optimize.minimze behavior based on initial conditions -


i'm testing out scipy.optimize project , found anomalous behavior when setting initial conditions minimizing using slsqp method. assume because sequential least squares algorithm, when initialized @ critical point (start_pos1) returns without checking second derivative conditions. looked through docs , didn't see anything, though--can tell what's going on?

from scipy import optimize import numpy np   def simplex(x):     return 1 - sum(x)  def sphere_min(x):     return sum(x[i]**2 in range(len(x)))**.5  def sphere_max(x):     return -sphere_min(x)   if __name__ == "__main__":     dimensions = 3     start_pos1 = np.ones(dimensions) * 1.0/dimensions     start_pos2 = [2*float(i+1)/(dimensions*(dimensions+1)) in range(dimensions)]     raw_start_pos = np.random.uniform(0, 1, dimensions)     start_pos3 = raw_start_pos/raw_start_pos.sum()      bnds = tuple((0, 1) in range(dimensions))     cons = ({'type': 'eq', 'fun': simplex})      start_pos in (start_pos1, start_pos2, start_pos3):         print 'start position: {}'.format(start_pos)         res = optimize.minimize(sphere_min, start_pos, method='slsqp', bounds=bnds, constraints=cons)         print 'min: x = {}, value = {}'.format(res.x, res.fun)         res = optimize.minimize(sphere_max, start_pos, method='slsqp', bounds=bnds, constraints=cons)         print 'max: x = {}, value = {}'.format(res.x, -res.fun)         print '\n==============\n' 


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -