Hi,
I am trying to optimize a function using l_bfgs constraint optimization routine in scipy. But the optimization routine passes values to the function, which are not with in the Bounds.
my full code looks like,
def humpy(aParams):
aParams = numpy.asarray(aParams)
print aParams
####
# connect to some other software for simulation
# data[1] & data[2] are read
##### objective function
val = sum(0.5*(data[1] - data[2])**2)
print val
return val
####
def approx_fprime():
####
Initial = numpy.asarray([10.0, 15.0, 50.0, 10.0])
interval = [(5.0, 60000.0),(10.0, 50000.0),(26.0, 100000.0),(8.0, 50000.0)]
opt = optimize.fmin_l_bfgs(humpy,Initial,fprime=approx_fprime, bounds=interval ,pgtol=1.0000000000001e-05,iprint=1, maxfun=50000)
print 'optimized parameters',opt[0]
print 'Optimized function value', opt[1]
####### the end ####
based on the initial values(Initial) and bounds(interval) opt = optimize.fmin_l_bfgs() will pass values to my software for simulation, but the values passed should be with in 'bounds'. Thats not the case..see below the values passed at various iterations
iter 1 = [ 10.23534209 15.1717302 50.5117245 10.28731118]
iter 2 = [ 10.23534209 15.1717302 50.01160842 10.39018429]
[ 11.17671043 15.85865102 50.05804208 11.43655591]
[ 11.17671043 15.85865102 50.05804208 11.43655591]
[ 11.28847754 15.85865102 50.05804208 11.43655591]
[ 11.17671043 16.01723753 50.05804208 11.43655591]
[ 11.17671043 15.85865102 50.5586225 11.43655591]
...............
...............
...............
[ 49.84670071 -4.4139714 62.2536381 23.3155698847]
at this iteration -4.4139714 is passed to my 2nd parameter but it should vary from (10.0, 50000.0), from where come -4.4139714 i don't know?
where should i change in the code? so that it passed values which should be with in bounds