optimization - Can the tol argument to R's optimize(fcn,...) be used to terminate iteration when the value of fcn is close enough to its minimum? -


i have been trying (with qualified success) minimize ill-behaved function using optimize. can reliably obtain acceptable solutions, more need be. best if optimize stop iterating when found function parameter produced return value near minimum. appears intent of tol argument optimize, have not been able make work expected. in code below, fcn prints current value of parameter optimized , fcn's return value (abs(x - target)), has minimum of zero.

trial 1:

optimize(fcn, interval=c(0.5,1), conn=10, tmtn=10 ,obst=28, tol=0.007) # 0.690983 0.513100 # 0.809017 0.373100 # 0.881966 0.214100 # 0.927051 0.079100 # 0.954915 0.046200 # 0.9647293 0.0844000 # 0.9453678 0.0099000 # 0.9430344 0.0045000   <-- should have terminated here # 0.9369293 0.0309000 # 0.9407011 0.0205000 # 0.9430344 0.0002000  # $minimum        $objective # [1] 0.9430344   [1] 2e-04 

trial 2

optimize(fcn, interval=c(0.2,1), conn=10,tmtn=10,obst=28, tol=0.007) # 0.5055728 0.6295000 # 0.6944272 0.5112000 # 0.8111456 0.3611000 # 0.8832816 0.2225000 # 0.927864 0.071300 # 0.9554175 0.0510000 # 0.9516505 0.0286000 # 0.9429519 0.0002000   <-- should have terminated here # 0.9371889 0.0342000 # 0.9462852 0.0108000 # 0.9429519 0.0099000  # $minimum        $objective # [1] 0.9429519   [1] 0.0099 

also, termination condition optimize? how in trial 2, optimize not terminate when fcn returns 0.0002, terminate when fcn returns 0.0099?


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -