[Rcpp-commits] r2758 - in pkg/RcppDE: . demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 10 05:13:32 CET 2010


Author: edd
Date: 2010-12-10 05:13:32 +0100 (Fri, 10 Dec 2010)
New Revision: 2758

Added:
   pkg/RcppDE/demo/environment.R
Modified:
   pkg/RcppDE/ChangeLog
   pkg/RcppDE/demo/00Index
Log:
added environment demo


Modified: pkg/RcppDE/ChangeLog
===================================================================
--- pkg/RcppDE/ChangeLog	2010-12-10 04:02:06 UTC (rev 2757)
+++ pkg/RcppDE/ChangeLog	2010-12-10 04:13:32 UTC (rev 2758)
@@ -1,3 +1,7 @@
+2010-12-09  Dirk Eddelbuettel  <edd at debian.org>
+
+	* demo/environment.R: Added new demo to show environment use
+
 2010-11-16  Dirk Eddelbuettel  <edd at debian.org>
 
 	* man/*.Rd: Added Author note for RcppDE.

Modified: pkg/RcppDE/demo/00Index
===================================================================
--- pkg/RcppDE/demo/00Index	2010-12-10 04:02:06 UTC (rev 2757)
+++ pkg/RcppDE/demo/00Index	2010-12-10 04:13:32 UTC (rev 2758)
@@ -2,3 +2,4 @@
 SmallBenchmark    repeated runs of RcppDE vs DEoptim on small vectors
 LargeBenchmark    single runs of RcppDE vs DEoptim on large vectors
 CompiledBenchmark single runs of RcppDE vs DEoptim on compiled objective function
+environment       simple example of using RcppDE with a user-supplied environemtn

Added: pkg/RcppDE/demo/environment.R
===================================================================
--- pkg/RcppDE/demo/environment.R	                        (rev 0)
+++ pkg/RcppDE/demo/environment.R	2010-12-10 04:13:32 UTC (rev 2758)
@@ -0,0 +1,16 @@
+
+suppressMessages(library(RcppDE))
+
+## somewhat pathodological example with nuisance parameter mul
+Rastrigin <- function(x) {
+    mul * (sum(x+2 - 10 * cos(2*pi*x)) + 20)
+}
+
+## create a new environment associated with the function
+funenv <- environment(fun=Rastrigin)
+assign("mul", 2, envir=funenv)        ## set value
+
+out <- DEoptim(Rastrigin, -25, 25,
+               control=list(NP=10, trace=0),
+               env=funenv)
+summary(out)



More information about the Rcpp-commits mailing list