[Rcpp-commits] r2373 - in pkg/RcppDE: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 31 03:35:52 CET 2010


Author: edd
Date: 2010-10-31 03:35:50 +0100 (Sun, 31 Oct 2010)
New Revision: 2373

Added:
   pkg/RcppDE/profile.r
Modified:
   pkg/RcppDE/ChangeLog
   pkg/RcppDE/benchmark.txt
   pkg/RcppDE/src/evaluate.cpp
Log:
evaluate simplified and thereby accelerated
logged some changes in ChangeLog
updated some benchmark results


Modified: pkg/RcppDE/ChangeLog
===================================================================
--- pkg/RcppDE/ChangeLog	2010-10-31 01:21:12 UTC (rev 2372)
+++ pkg/RcppDE/ChangeLog	2010-10-31 02:35:50 UTC (rev 2373)
@@ -1,3 +1,29 @@
+2010-10-30  Dirk Eddelbuettel  <edd at debian.org>
+
+	* profile.r: Simple front-end script used for profiling runs
+
+	* src/evaluate.cpp: Slight performance increase and simplification
+
+	* benchmark.txt: Updated benchmark results, including one on OS X
+
+2010-10-30  Dirk Eddelbuettel  <edd at debian.org>
+
+	* benchmark.r: Now calls demo/benchmark.r, minor edits
+	* bigBenchmark.r: Now calls demo/bigBenchmark.r, minor edits
+
+2010-10-27  Dirk Eddelbuettel  <edd at debian.org>
+
+	* benchmark.txt: Updated benchmark results, including one on OS X
+	* src/de4_0.cpp: Minor edits
+
+2010-10-26  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/de4_0.cpp:
+	  - corrected sortindex error for strat=6
+	  - corrected inner loop when bs=TRUE
+
+	* DESCRIPTION: explicit Depends: on RcppArmadillo (>= 0.2.8)
+	
 2010-10-19  Dirk Eddelbuettel  <edd at debian.org>
 
 	* R/DEoptim.R:

Modified: pkg/RcppDE/benchmark.txt
===================================================================
--- pkg/RcppDE/benchmark.txt	2010-10-31 01:21:12 UTC (rev 2372)
+++ pkg/RcppDE/benchmark.txt	2010-10-31 02:35:50 UTC (rev 2373)
@@ -511,3 +511,42 @@
 Genrose200    16.828 15.397          0.91496        8.5037
 MEANS         11.212 10.543          0.94037        5.9629
 # Done  2010-10-27 21:56:24.62256  
+
+
+romain@ ~/svn/rcpp/pkg/RcppDE/demo $ Rscript SmallBenchmark.R
+
+DEoptim package
+Differential Evolution algorithm in R
+Authors: David Ardia and Katharine Mullen
+# At 2010-10-30 09:37:15
+               DEoptim   RcppDE ratioRcppToBasic pctGainOfRcpp
+Rastrigin5  0.1173750 0.120375        1.0255591   -2.55591054
+Rastrigin10 0.2581250 0.261250        1.0121065   -1.21065375
+Rastrigin20 0.6117500 0.606875        0.9920311    0.79689416
+Wild5       0.1786250 0.202125        1.1315605  -13.15605318
+Wild10      0.4220000 0.398500        0.9443128    5.56872038
+Wild20      1.0581250 1.052500        0.9946840    0.53160071
+Genrose5    0.2046250 0.205125        1.0024435   -0.24434942
+Genrose10   0.4595000 0.461875        1.0051687   -0.51686616
+Genrose20   1.1097500 1.110375        1.0005632   -0.05631899
+MEANS       0.4910972 0.491000        0.9998020    0.01979694
+# Done 2010-10-30 09:38:50
+romain@ ~/svn/rcpp/pkg/RcppDE/demo $
+romain@ ~/svn/rcpp/pkg/RcppDE/demo $ Rscript LargeBenchmark.R
+
+DEoptim package
+Differential Evolution algorithm in R
+Authors: David Ardia and Katharine Mullen
+# At 2010-10-30 09:40:05
+               DEoptim   RcppDE ratioRcppToBasic pctGainOfRcpp
+Rastrigin50   1.95600  1.98900        1.0168712    -1.6871166
+Rastrigin100  5.25200  4.91900        0.9365956     6.3404417
+Rastrigin200 14.20800 12.30900        0.8663429    13.3657095
+Wild50        3.42000  3.44800        1.0081871    -0.8187135
+Wild100       9.03800  9.18800        1.0165966    -1.6596592
+Wild200      25.81700 28.24300        1.0939691    -9.3969090
+Genrose50     4.11200  3.70900        0.9019942     9.8005837
+Genrose100    8.97200  8.83100        0.9842844     1.5715560
+Genrose200   24.69300 26.59400        1.0769854    -7.6985380
+MEANS        10.82978 11.02556        1.0180777    -1.8077728
+# Done 2010-10-30 09:43:23

Added: pkg/RcppDE/profile.r
===================================================================
--- pkg/RcppDE/profile.r	                        (rev 0)
+++ pkg/RcppDE/profile.r	2010-10-31 02:35:50 UTC (rev 2373)
@@ -0,0 +1,14 @@
+#!/usr/bin/r -t
+
+suppressMessages(library(RcppDE))
+
+Genrose <- function(x) { 	## One generalization of the Rosenbrock banana valley function (n parameters)
+    n <- length(x)
+    1.0 + sum (100 * (x[-n]^2 - x[-1])^2 + (x[-1] - 1)^2)
+}
+
+
+maxIt <- 2500                            # not excessive but so that we get some run-time on simple problems
+n <- 100
+
+RcppDE::DEoptim(fn=Genrose, lower=rep(-25, n), upper=rep(25, n), control=list(NP=10*n, itermax=maxIt, trace=FALSE))


Property changes on: pkg/RcppDE/profile.r
___________________________________________________________________
Added: svn:executable
   + *

Modified: pkg/RcppDE/src/evaluate.cpp
===================================================================
--- pkg/RcppDE/src/evaluate.cpp	2010-10-31 01:21:12 UTC (rev 2372)
+++ pkg/RcppDE/src/evaluate.cpp	2010-10-31 02:35:50 UTC (rev 2373)
@@ -9,23 +9,15 @@
 
 // Slighly accelerated version of evaluate to evaluate function fcall with parameters param in environment env
 // Uses externally allocated par() vector into which param are copied
-//
 double evaluate(long &l_nfeval, const double *param, SEXP par, SEXP fcall, SEXP env) {
-    // -- safer approach: cast to NumericVector, fill it and eval
-    //Rcpp::NumericVector parvec(par); 			// access parS as numeric vector to fill it
-    //memcpy(parvec.begin(), param, parvec.size() * sizeof(double));
-    //SEXP fn = ::Rf_lang2(fcall, parvec); 			// this could be done with Rcpp 
-
-    // -- faster: direct access _assuming_ numeric vector
-    memcpy(REAL(par), param, Rf_nrows(par) * sizeof(double));
-
-    SEXP fn = ::Rf_lang2(fcall, par); 			// this could be done with Rcpp 
-    SEXP sexp_fvec = ::Rf_eval(fn, env);		// but is still a lot slower right now
-
-    double f_result = Rcpp::as<double>(sexp_fvec);
+    memcpy(REAL(par), param, Rf_nrows(par) * sizeof(double));      // -- faster: direct access _assuming_ numeric vector
+    SEXP fn = ::Rf_lang2(fcall, par); 				   // this could be done with Rcpp 
+    SEXP sexp_fvec = ::Rf_eval(fn, env);		           // but is still a lot slower right now
+    double f_result = REAL(sexp_fvec)[0];
     if (ISNAN(f_result)) 
 	::Rf_error("NaN value of objective function! \nPerhaps adjust the bounds.");
-    l_nfeval++;  					// increment function evaluation count 
-   return(f_result); 
+    l_nfeval++;  						   // increment function evaluation count 
+    return(f_result); 
 }
 
+



More information about the Rcpp-commits mailing list