Bug 15052 - nlminb() hangs if all functions return NA
Summary: nlminb() hangs if all functions return NA
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 2.15.1 patched
Hardware: x86_64/x64/amd64 (64-bit) Linux-Ubuntu
: P5 enhancement
Assignee: R-core
Depends on:
Reported: 2012-09-19 11:22 UTC by Sebastian Meyer
Modified: 2014-02-16 11:41 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Meyer 2012-09-19 11:22:59 UTC
The nlminb() optimizer hangs (with continuous 100% CPU usage) if all functions (objective, gradient, hessian) return NA values. This should of course not be the standard use case...

Reproducible code:

f <- function (x) NA_real_
gr <- function (x) rep.int(NA_real_, length(x))
hess <- function (x) matrix(NA_real_, length(x), length(x))

nlminb(1:5, f, gr, hess)

The session can't be interrupted by the BREAK signal (C-c), thus I suppose the problem is in the C code.

Similarly, nlminb() is heavily occupied if the objective function and the hessian return NA values, but the gradient returns a numeric vector as intended (even the 0-vector)

nlminb(1:5, f, function(x) rep.int(0, length(x)), hess)

However, there is no such problem with

nlminb(1:5, f, hessian=hess)


nlminb(1:5, f, gradient=gr)

--- session info:
R Under development (unstable) (2012-09-19 r60760)
Platform: x86_64-unknown-linux-gnu (64-bit)
Comment 1 Brian Ripley 2012-09-23 15:29:41 UTC
It fails in the Fortran code.

Although the help page claims NA/infinite values are supported, I see nothing in the Fortran code to support the claim.  So I've removed the claim.
Comment 2 Brian Ripley 2012-09-26 07:56:56 UTC
Workaround to replace NA/NaN in function evaluations by +Inf seems to work.
Comment 3 Jackie Rosen 2014-02-16 11:41:42 UTC
(spam comment removed)