adcomp icon indicating copy to clipboard operation
adcomp copied to clipboard

Automatic detection of numerical overflow?

Open James-Thorson opened this issue 10 years ago • 1 comments

Hi all,

I have a model where I'm reasonably sure that I've diagnosed the following problem. Namely, this model (and others I've seen) given a certain configuration would end up with the final gradient from nlminb optimization going to absurdly high values (10^10 and such). In my experience, this occurs when the inner-optimization fails for some proposals near the final value (i.e. the inner optimizer throws a warning message about not converging during some proposals during Nelder-Mead explorations, but where this doesn't happen during the call to the gradient, which appears to crash nlminb). The problem went away when I changed the model to be less prone to numerical overflow (i.e., by simplifying slightly, such that instead of exponentiating a predicted value, calculating the likelihood, and then taking the log of the likelihood, I could calculate the log-likelihood directly).

So this leads to several questions:

  1. Is there any way to directly check whether I have a numerical overflow, i.e., a function to call on the objective function to detect these instances?
  2. Is it possible to build numerical overflow detection into the MakeADFun function call? This issue can sometimes be subtle (given unbounded exploration of random effects), so I recommend a generic warning message by default.

I welcome any thoughts, jim

James-Thorson avatar Jun 09 '15 21:06 James-Thorson

Hi Jim,

Regarding 1) you can trap overflow in the debugger (gdb) if you are using linux:

http://folk.uib.no/hsk021/tmbdoc/group__Errors.html

(section Floating point execption)

Unfortunately gdb only work under linux with the current TMB setup. It is highly recommended to have access to a linux server with TMB installed solely for the purpose of being able to run the debugger.

Hans

skaug avatar Jun 10 '15 07:06 skaug