Tuesday, January 19, 2016

SciPy infeasibility error

This model


is obviously infeasible. However SciPy’s SLSQP algorithm returns as if everythin is hunky-dory:


(I hope I did not make a mistake here: things are not as readible as I would like). R also has an interface to SLSQP. Here we see some flags being raised:

> slsqp(c(1,2),
+       function(x) {x[1]^2+x[2]^2},
+       heq=function(x){x[1]+x[2]-1},
+       hin=function(x){x[1]-2},
+       lower=c(0,0))
[1] 1.666667e+00 4.773719e-11

[1] 2.777778

[1] 105

[1] -4

[1] "NLOPT_ROUNDOFF_LIMITED: Roundoff errors led to a breakdown of the optimization algorithm. In this case, the returned minimum may still be useful. (e.g. this error occurs in NEWUOA if one tries to achieve a tolerance too close to machine precision.)"