import numpy
from numpy import asarray
Initial = numpy.asarray [2.0, 4.0, 5.0, 3.0, 5.0, 6.0] # Initial values to start with
bounds = [(1, 5000), (1, 6000), (2, 100000), (1, 50000), (1.0, 5000), (2, 1000000)]
# actual passed bounds
b1 = lambda x: numpy.asarray([1.4*x[0] - x[0]])
b2 = lambda x: numpy.asarray([1.4*x[1] - x[1]])
b3 = lambda x: numpy.asarray([x[2] - x[3]])
constraints = numpy.asarray([b1, b2, b3])
opt= optimize.fmin_slsqp(func,Initial,ieqcons=constraints,bounds=bounds, full_output=True,iter=200,iprint=2, acc=0.01)
Problem: I want to pass in inequality constraints. Consider that I have 6 parameters
[ a, b, c, d, e, f]
in the Initial
values, and my constraints are:
a<=e<=1.4*a ('e' varies from a to 1.4*a)
b<=f<=1.4*b ('f' varies from b to 1.4*b)
c>d ('c' must always be greater than d)
But this is not working properly. I don't know what the mistake is. Is there any better way to pass my constraints as a function? Please help me.