R Under development (unstable) (2025-02-17 r87739 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(Rcpp) > library(RcppDE) Now loading: RcppDE: C++ Implementation of Differential Evolution Optimisation Author: Dirk Eddelbuettel Based on: DEoptim (version 2.0-7): Differential Evolution algorithm in R Authors: David Ardia, Katharine Mullen, Brian Peterson and Joshua Ulrich > > set.seed(1234) > > Rosenbrock <- function(x) { + + # briefly, calls to functions generated with Rcpp Attributes + # could break optimizers due to incorrect sync of RNG state + RcppDE:::putFunPtrInXPtr("dummy") + + x1 <- x[1] + x2 <- x[2] + 100 * (x2 - x1 * x1) ^ 2 + (1 - x1) ^ 2 + } > > lower <- c(-10, -10) > upper <- -lower > cont <- DEoptim.control(trace = 0) > > fit <- DEoptim(Rosenbrock, lower, upper, control = cont) > > if (packageVersion("Rcpp") >= "0.12.17.1") + stopifnot(all.equal(fit$optim$bestmem, c(par1 = 1, par2 = 1))) > > proc.time() user system elapsed 0.23 0.09 0.31