MyNixOS website logo
Description

R Interface to NLopt.

Solve optimization problems using an R interface to NLopt. NLopt is a free/open-source library for nonlinear optimization, providing a common interface for a number of different free optimization routines available online as well as original implementations of various other algorithms. See <https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/> for more information on the available algorithms. Building from included sources requires 'CMake'. On Linux and 'macOS', if a suitable system build of NLopt (2.7.0 or later) is found, it is used; otherwise, it is built from included sources via 'CMake'. On Windows, NLopt is obtained through 'rwinlib' for 'R <= 4.1.x' or grabbed from the appropriate toolchain for 'R >= 4.2.0'.

nloptr

R-CMD-check test-coverage Codecov testcoverage pkgdown CRANstatus

nloptr is an R interface to NLopt, a free/open-source library for nonlinear optimization started by Steven G. Johnson, providing a common interface for a number of different free optimization routines available online as well as original implementations of various other algorithms. It can be used to solve general nonlinear programming problems with nonlinear constraints and lower and upper bounds for the controls, such as

$$ \min_{x \in \mathbb{R}^n} \quad f(x), $$

s.t. $g(x) \le 0$, $h(x) = 0$ and $\ell \le x \le u$.

The NLopt library is available under the GNU Lesser General Public License (LGPL), and the copyrights are owned by a variety of authors. See the website for information on how to cite NLopt and the algorithms you use.

Installation

Windows

On Windows, either the latest version 2.7.1 of NLopt from rwinlib (windows-release) or the v2.7.1 build from the rtools42 toolchain (windows2022-devel) is used. So there is nothing else to be done.

Linux and macOS

On Unix-like platforms, we use pkg-config to find a suitable system build of NLopt (i.e. with version >= 2.7.0).

  • If it is found it is used.
  • Otherwise, NLopt 2.7.1 is built from included sources using CMake. In this case, a binary of CMake stored in environment variable CMAKE_BIN is searched on the PATH and, alternatively, on a macOS-specific location. If that variable cannot be set, install will abort suggesting ways of installing CMake. The minimal version requirement on cmake is >= 3.15.0.

Installing CMake (macOS and Linux only)

Minimal version requirement for cmake is 3.2.0.

You can install CMake by following CMake installation instructions. The important thing is that you add the CMake binary to your PATH:

  • On macOS, you can install CMake and then run it. In the menu bar, there is an item How to Install For Command Line Use which you can click on to have proper instructions on how to update your PATH. Note that the location of the CMake binary is always /Applications/CMake.app/Contents/bin/cmake. Hence, nloptr knows where to find it even if you do not update your PATH.
  • On Linux, it will be automatically added unless you specifically change the default installation directory before building CMake.

Alternatively, you can set an environment variable CMAKE_BIN pointing to a CMake binary of your liking on your computer for nloptr to use.

Installing nloptr

You can install nloptr from CRAN using:

install.packages("nloptr")

Alternatively, you can install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("astamm/nloptr")

Acknowledgments

I would like to express my sincere gratitude to Dirk Eddelbuettel, Jeroen Ooms, Tomas Kalibera, Uwe Ligges and Jelmer Ypma for their contributions and the very instructive discussions about the pros and cons of various build strategies in R packages.

Reference

Steven G. Johnson, The NLopt nonlinear-optimization package, https://nlopt.readthedocs.io/en/latest/

Metadata

Version

2.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows