Scipy.optimize termina exitosamente para NLP no factible

Intenté resolver una PNL usando el scipy.optimize SLSQP. El problema es claramente inviable, pero la función de minimizar en scipy.optimize parece estar en desacuerdo.

minimize X^2 + Y^2 subject to X + Y = 11 X, Y >= 6 

El código:

 from scipy.optimize import minimize def obj(varx): return varx[1]**2 + varx[0]**2 def constr1(varx): constr1 = -varx[0]-varx[1]+11 return constr1 bnds = [(6,float('Inf')),(6,float('Inf'))] ops = ({'maxiter':100000, 'disp':'bool'}) cons = ({'type':'eq', 'fun':constr1}) res = minimize(obj, x0=[7,7], method='SLSQP', constraints = cons, bounds = bnds, options = ops) print res.x print res.success 

La salida:

 Optimization terminated successfully. (Exit mode 0) Current function value: 72.0 Iterations: 6 Function evaluations: 8 Gradient evaluations: 2 [ 6. 6.] True 

¿Me estoy perdiendo de algo?

Puedes probar el mystic . No logra resolver el problema para soluciones no viables a las restricciones. Aunque no es “obvio” (tal vez), devuelve un inf para soluciones no factibles … Supongo que el comportamiento podría mejorarse (soy el autor) para que sea más obvio que solo se encuentran soluciones no factibles.

 >>> def objective(x): ... return x[0]**2 + x[1]**2 ... >>> equations = """ ... x0 + x1 = 11 ... """ >>> bounds = [(6,None),(6,None)] >>> >>> from mystic.solvers import fmin_powell, diffev2 >>> from mystic.symbolic import generate_constraint, generate_solvers, simplify >>> >>> cf = generate_constraint(generate_solvers(simplify(equations))) >>> >>> result = fmin_powell(objective, x0=[10,10], bounds=bounds, constraints=cf, gtol=50, disp=True, full_output=True) Warning: Maximum number of iterations has been exceeded >>> result[1] array(inf) >>> >>> result = diffev2(objective, x0=bounds, bounds=bounds, constraints=cf, npop=40, gtol=50, disp=True, full_output=True) Warning: Maximum number of iterations has been exceeded >>> result[1] inf