nloptr provides an R interface to NLopt, a free/open-source library for nonlinear optimization providing a common interface to a number of different optimization routines which can handle nonlinear constraints and lower and upper bounds for the controls.
parallel::detectCores() may return NA in cases that it fails to guess. In those cases we want to use the default.