← Back to all sparks
N

n1qn1c

ANALYTICS
Velocity0.0

Port of the Scilab n1qn1 Module for Unconstrained BFGS Optimization

A Fortran-descended optimizer got thread-safe, then found two flags that never worked.

numerical-optimizationquasi-newtonthread-safetymemory-safetyfortran-to-cr-package
Current state
n1qn1c is a quasi-Newton optimization routine translated from Fortran to C, used as a solver backend by the nlmixr2 modeling stack rather than called directly by most users. Its two 2026 releases are a concentrated safety pass: global state converted to thread_local, static removed from local variables in the translated code, integer overflow guards added, and memory leaks closed in the R callback wrappers — plus the gcc-asan and valgrind fixes CRAN asked for.
Where it's heading
The package is being hardened for use inside a parallel modeling framework rather than extended. The audit that produced the thread-safety work also surfaced two plain bugs in features users would have assumed worked: restart = TRUE left the mode at 2 instead of 3 because of a typo, and assign = TRUE referenced the wrong field name so the compressed Hessian was never written to the supplied environment. Earlier work points the same direction — the 6.0.1-12 function-pointer interface exists so nlmixr2est does not need resubmission when this package changes.
Prediction
Expect further memory-safety and sanitizer work rather than algorithmic change; a Fortran-translated numerical core under CRAN's checking regime generates that kind of release indefinitely.

Recent moves

  1. 4mo ago

    restart and assign flags fixed; sanitizer issues cleared

    Restates the thread-safety work from the prior release and adds what the audit turned up: restart = TRUE never actually set mode to 3, assign = TRUE never stored the compressed Hessian because of a wrong field name, EvalBase lacked a virtual destructor making deletion through a base pointer undefined, and bad inputs leaked callback objects. The gcc-asan and valgrind fixes CRAN requested land here too.

    View source ↗
  2. 4mo ago

    Global state converted to thread_local

    The thread-safety conversion itself: global state becomes thread_local, static is stripped from local variables in the Fortran-translated C, integer overflow guards go in, and the R callback wrappers stop leaking. Necessary groundwork for a solver called from a framework that fits models in parallel.

    View source ↗
  3. 1y ago

    Function-pointer API decouples nlmixr2est releases

    A non-binary function pointer interface added specifically so nlmixr2est no longer needs resubmission when this package changes. A packaging concern rather than a numerical one, but it is what lets the safety work above ship without dragging the dependent through CRAN.

    View source ↗