I use Python 2.5.
I am passing bounds to the cobyla optimisation:
import numpy
from numpy import asarray
Initial = numpy.asarray [2, 4, 5, 3] # Initial values to start with
#bounding limits (lower,upper) - for visualizing
#bounds = [(1, 5000), (1, 6000), (2, 100000), (1, 50000)]
# actual passed bounds
b1 = lambda x: 5000 - x[0] # lambda x: bounds[0][1] - Initial[0]
b2 = lambda x: x[0] - 2.0 # lambda x: Initial[0] - bounds[0][0]
b3 = lambda x: 6000 - x[1] # same as above
b4 = lambda x: x[1] - 4.0
b5 = lambda x: 100000 - x[2]
b6 = lambda x: x[2] - 5.0
b7 = lambda x: 50000 - x[3]
b8 = lambda x: x[3] - 3.0
b9 = lambda x: x[2] > x[3] # very important condition for my problem!
opt= optimize.fmin_cobyla(func,Initial,cons=[b1,b2,b3,b4,b5,b6,b7,b8,b9,b10],maxfun=1500000)
Based on the initial values Initial
and as per/within the bounds b1
to b10
the values are passed to opt()
. But the values are deviating, especially with b9
. This is a very important bounding condition for my problem!
"The value of x[2]
passed to my function opt()
at every iteration must be always greater than x[3]
" -- How is it possible to achieve this?
Is there anything wrong in my bounds (b1
to b9
) definition ?
Or is there a better way of defining of my bounds?
Please help me.