| Title: | 'nloptr' Plug-in for the 'R' Optimization Infrastructure |
|---|---|
| Description: | Enhances the R Optimization Infrastructure ('ROI') package with the 'NLopt' solver for solving nonlinear optimization problems. |
| Authors: | Florian Schwendinger [aut, cre] |
| Maintainer: | Florian Schwendinger <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0-0 |
| Built: | 2026-05-17 07:10:20 UTC |
| Source: | https://github.com/r-forge/roi |
The following example solves the Rosenbrock function (https://en.wikipedia.org/wiki/Rosenbrock_function).
library(ROI) f <- function(x) { return( 100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2 ) } f.gradient <- function(x) { return( c( -400 * x[1] * (x[2] - x[1] * x[1]) - 2 * (1 - x[1]), 200 * (x[2] - x[1] * x[1])) ) } x <- OP( objective = F_objective(f, n = 2L, G = f.gradient), bounds = V_bound(ld = -3, ud= 3, nobj = 2L) ) nlp <- ROI_solve(x, solver = "nloptr.lbfgs", start = c(-1.2, 1)) nlp ## Optimal solution found. ## The objective value is: 1.189412e-15 solution(nlp) ## [1] 1 1library(ROI) f <- function(x) { return( 100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2 ) } f.gradient <- function(x) { return( c( -400 * x[1] * (x[2] - x[1] * x[1]) - 2 * (1 - x[1]), 200 * (x[2] - x[1] * x[1])) ) } x <- OP( objective = F_objective(f, n = 2L, G = f.gradient), bounds = V_bound(ld = -3, ud= 3, nobj = 2L) ) nlp <- ROI_solve(x, solver = "nloptr.lbfgs", start = c(-1.2, 1)) nlp ## Optimal solution found. ## The objective value is: 1.189412e-15 solution(nlp) ## [1] 1 1