R-CMD-check CRAN status License: GPL v3

ucminfcpp

R package that provides unconstrained nonlinear optimization through a modern C++17 reimplementation of the classic Fortran-based ucminf algorithm. It is a drop-in replacement for ucminf::ucminf(). The reimplementation of the C++ library offers multi-language support for Python and Julia .

Features

Installation

Install the latest development version from GitHub:

# Install directly from GitHub
devtools::install_github("alrobles/ucminfcpp")

Basic Example

The example below optimises Rosenbrock’s Banana Function and confirms that ucminfcpp and ucminf produce identical results.

# Rosenbrock's Banana Function
banana <- function(x) {
  100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2
}

# Initial point
starting_point <- c(-1.2, 1)

# Optimization with ucminfcpp
result_cpp <- ucminfcpp::ucminf(starting_point, banana)
cat("ucminfcpp result:\n")
print(result_cpp$par)

# Optimization with ucminf
result_fortran <- ucminf::ucminf(starting_point, banana)
cat("ucminf result:\n")
print(result_fortran$par)

# Check similarity
identical_result <- all.equal(result_cpp$par, result_fortran$par)
cat("Are the results the same? ", identical_result, "\n")

Overview

ucminfcpp provides the ucminf() function for general-purpose unconstrained nonlinear optimization. The algorithm is a quasi-Newton method with BFGS updating of the inverse Hessian and a soft line search with adaptive trust-region radius monitoring.

It is designed as a drop-in replacement for the original Fortran-based ucminf ucminf::ucminf() function. The original algorithm was written in Fortran by Hans Bruun Nielsen.

Complete Credit

This reimplementation is based on the original repository ucminf.

The implementation and techniques are derived from the original Fortran-based algorithm described by: Nielsen, H. B. (2000) UCMINF - An Algorithm For Unconstrained, Nonlinear Optimization, Report IMM-REP-2000-19, Department of Mathematical Modelling, Technical University of Denmark.

Dr. Nielsen passed away in 2015; the code was later modified for integration with R packages. The structure of ucminf in R draws from the FortranCallsR package by Diethelm Wuertz. Dr. Wuertz passed away in 2016

Further Reading