Antonio Coppola edited Examples.tex  over 9 years ago

Commit id: 9cd0e633edf6873fb96d46f81cd704c90385ebe9

deletions | additions      

       

We begin by using lbfgs to minimize a suite of simple test functions, and benchmarking the package against the L-BFGS-B optim method.  \begin{itemize}  \item \textit{The Rosenbrock function:} We define the Rosenbrock function mapping $\mathbf{R}^2$ to $\mathbf{R}$ as $f(x,y) = 100 \cdot (y - x^2)^2 + (1 - x)^2$. The function has a global minimum at $(0,0)$ that lies within a a long, flat valley. We define the function and its gradient as R object, objects,  and then run the optimization routine: routine using both lbfgs and optim:  \begin{lstlisting}  objective <- function(x) {   100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2 

200 * (x[2] - x[1]^2))  }  out out.lbfgs  <- lbfgs(objective, gradient, c(-1.2, 1)) out.optim <- optim(c(-1.2, 1), objective, gradient)  \end{lstlisting}  The results are the following:  \begin{lstlisting}  \end{lstlisting}  \end{itemize}