Open
Description
Bug 17703 documents a case where constrOptim()
throws an error for a well-spedified constrained optimization problem. The error is thrown because the objective function becomes non-finite due to imprecision caused by floating-point arithmetic. In particular, the error is triggered by a check for negative values in object gi
on L32 (prior to a log(gi)
computation that would produce NaN
for negative values).
@mmaechler indicates that a patch would be welcome along the following lines:
- Avoid false precision by removing noise from
gi
before checking, e.g. withsignif(gi, digits)
, wheredigits
is a new argument - Update the corresponding help file
constrOptim.Rd
Note: bug report specifies this as an issue in R-3.6.2, I have confirmed this is still present in R-devel (2025/05/15, r88203).