if (identical(Sys.getenv("AUTO_JULIA_INSTALL"), "true")) { ## julia_setup is quite time consuming
## do initialization and automatic installation of Julia if necessary
julia_setup(installJulia = TRUE)
julia_install_package_if_needed("Optim")
opt <- julia_pkg_import("Optim",
func_list = c("optimize", "BFGS"))
rosenbrock <- function(x) (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
result <- opt$optimize(rosenbrock, rep(0,2), opt$BFGS())
result
}
Run the code above in your browser using DataLab