This post is a sequel to the previous article on how to use the old Fortran code to solve optimization problems in C++ applications. This time we consider the L-BFGS-B algorithm for solving smooth and box-constrained optimization problems of the form $$ \begin{align*} \min_{x}\quad & f(x)\\ \text{subject to}\quad & l\le x\le u, \end{align*} $$ where $l$ and $u$ are simple bounds for $x\in\mathbb{R}^n$, and can take $-\infty$ and $+\infty$ values.

L-BFGS is a well-known and widely-used optimization algorithm for smooth and unconstrained optimization problems. It was originally implemented in Fortran, and also has some more recent implementations including libLBFGS and my own LBFGS++.
The Fortran code was written more than 30 years ago, and looks a bit exotic from today’s perspective. However, it is still one of the most stable and mature implementations of the L-BFGS algorithm, and is typically used as a baseline in testing and benchmarking.

Introduction I have seen several conversations in Rcpp-devel mailing list asking how to compute numerical integration or optimization in Rcpp. While R in fact has the functions Rdqags, Rdqagi, nmmin, vmmin etc. in its API to accomplish such tasks, it is not so straightforward to use them with Rcpp.
For my own research projects I need to do a lot of numerical integration, root finding and optimization, so to make my life a little bit easier, I just created the RcppNumerical package that simplifies these procedures.

This semester I’m taking a course in big data computing using Scala/Spark, and we are asked to finish a course project related to big data analysis. Since statistical modeling heavily relies on linear algebra, I investigated some existing libraries in Scala/Java that deal with matrix and linear algebra algorithms.
1. Set-up Scala/Java libraries are usually distributed as *.jar files. To use them in Scala, we can create a directory to hold them and set up the environment variable to let Scala know about this path.