scipy.optimize.slsqp.fmin_slsqp - Inequality constraints incompatible

classic Classic list List threaded Threaded
1 message Options
fj
Reply | Threaded
Open this post in threaded view
|

scipy.optimize.slsqp.fmin_slsqp - Inequality constraints incompatible

fj
I am using SciPy 0.10.1 and the following code stops at Inequality constraints incompatible (Exit mode 4) error. Can I avoid it? I suspect that the error is connected with bounds, because it works without them. Thank you.

import scipy.optimize

upper_bounds = [91680237, 87141351, 19183473, 84453111]
x0 = [1461516, 1230049, 0, 0]

ieqcons = [
    lambda x: 3139153 - (x[0] + x[1] + x[2] + x[3]),
    lambda x: 1461516 - (x[0] + x[2] + x[3]),
    lambda x: 1230049 - (x[1] + x[2]),
]

scipy.optimize.slsqp.fmin_slsqp(
    func=lambda x: sum((x[i] - upper_bounds[i])**2 for i in xrange(4)),
    fprime=lambda x: [2 * (x[i] - upper_bounds[i]) for i in xrange(4)],
    x0=x0,
    bounds=[(0, b) for b in upper_bounds],
    ieqcons=ieqcons,
    iprint=2,
)