Tingting Zhan
2011-Aug-15 18:52 UTC
[R] Stopping criterion in option "control" of BBsolve( )
Dear Dr. Gilbert, Dr. Varadhan and all R-help list members, I'm using the function BBsolve( ) and I have some questions on the stopping criterion "maxit" and "noimp" specified in the option "control". Here are two such examples I'm having problem with. In these two examples, the function BBsolve( ) always stops at iteration 100, overlooking the values I specified in "control". Any advise are greatly appreciated! Sincerely yours, Tingting Zhan Example 1: The equation tst.fn() returns vector-0 after 2 seconds of running. I think I should have the BBsolve() function run about 2 seconds and then successfully converge. I specified maxit and noimp as large as 10000. However, the BBsolve function returns nonconvergence only after 0.25 seconds and after 100 iterations.> tst.fn = function(x){ if((proc.time() - R.ptm)[3] > 2) { cat("overtime.\n"); return(c(0,0)); } else { return(c(2,2)); } }> system.time( { R.ptm = proc.time(); tst = BBsolve(par=c(1,1), fn tst.fn , control = list(maxit = 10000, noimp=10000)) } )Unsuccessful convergence. user system elapsed 0.25 0.00 0.25> tst$par [1] 0.5 0.6 $residual [1] 2 $fn.reduction [1] 0 $feval [1] 186 $iter [1] 100 $convergence [1] 5 $message [1] "Lack of improvement in objective function" $cpar method M NM 2 50 1 Example 2: The equation tst.fn() returns a constant vector c(2,2), thus it will never converge. I specified maxit = 1000 and noimp=10, however the BBsolve() function stops at iteration 100, as I'm unclear where does the number 100 comes from.> tst.fn = function(x) { c(2,2) }> system.time( { tst = BBsolve(par=c(1,1), fn = tst.fn , control list(maxit = 1000, noimp=20)) } )Unsuccessful convergence. user system elapsed 0.16 0.00 0.15> tst$par [1] 1 1 $residual [1] 2 $fn.reduction [1] 0 $feval [1] 186 $iter [1] 100 $convergence [1] 5 $message [1] "Lack of improvement in objective function" $cpar method M NM 2 50 1 abc [[alternative HTML version deleted]]