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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Oct 16 23:49:57 CEST 2010


Author: edd
Date: 2010-10-16 23:49:57 +0200 (Sat, 16 Oct 2010)
New Revision: 2321

Modified:
   pkg/RcppDE/benchmark.txt
   pkg/RcppDE/src/de4_0.cpp
Log:
eliminate a bunch of 'element copy loops' near the end


Modified: pkg/RcppDE/benchmark.txt
===================================================================
--- pkg/RcppDE/benchmark.txt	2010-10-16 21:42:21 UTC (rev 2320)
+++ pkg/RcppDE/benchmark.txt	2010-10-16 21:49:57 UTC (rev 2321)
@@ -207,3 +207,21 @@
 Genrose50   2.527722 2.571667           1.0174      -1.73850
 MEANS       0.563150 0.571806           1.0154      -1.53699
 
+
+# At  2010-10-16 16:47:29.41668
+# SVN  2320M 
+             DEoptim   RcppDE ratioRcppToBasic pctGainOfRcpp
+Rastrigin2  0.039889 0.042667           1.0696     -6.963788
+Rastrigin5  0.104833 0.110611           1.0551     -5.511394
+Rastrigin20 0.539778 0.555278           1.0287     -2.871552
+Wild2       0.066167 0.068222           1.0311     -3.106633
+Wild5       0.181444 0.186111           1.0257     -2.571953
+Wild20      1.037778 1.048944           1.0108     -1.076017
+Genrose2    0.070111 0.072222           1.0301     -3.011094
+Genrose5    0.186667 0.189833           1.0170     -1.696429
+Genrose20   0.905167 0.905611           1.0005     -0.049101
+Genrose50   2.530556 2.589778           1.0234     -2.340285
+MEANS       0.566239 0.576928           1.0189     -1.887700
+
+
+

Modified: pkg/RcppDE/src/de4_0.cpp
===================================================================
--- pkg/RcppDE/src/de4_0.cpp	2010-10-16 21:42:21 UTC (rev 2320)
+++ pkg/RcppDE/src/de4_0.cpp	2010-10-16 21:49:57 UTC (rev 2321)
@@ -374,46 +374,50 @@
 		} while (!done);   // do .. while 
 	    } // while (step > 1) 
 	    /* now the best NP are in first NP places in gta_pop, use them */
-	    for (i = 0; i < i_NP; i++) {
-		for (j = 0; j < i_D; j++) 
-		    ta_newP.at(i,j) = ta_popP.at(i,j);
-		ta_newC[i] = ta_popC[i];
-	    }
-	} /*i_bs_flag*/
+	    // for (i = 0; i < i_NP; i++) {
+	    // 	for (j = 0; j < i_D; j++) 
+	    // 	    ta_newP.at(i,j) = ta_popP.at(i,j);
+	    // 	ta_newC[i] = ta_popC[i];
+	    // }
+	    ta_newP = ta_popP;
+	    ta_newC = ta_popC;
+	} // i_bs_flag
 
-	/* have selected NP mutants move on to next generation */
-	for (i = 0; i < i_NP; i++) {
-	    for (j = 0; j < i_D; j++) 
-		ta_oldP.at(i,j) = ta_newP.at(i,j);
-	    ta_oldC[i] = ta_newC[i];
-	}
-	/* check if the best stayed the same, if necessary */
-	if(i_check_winner)  {
+	// have selected NP mutants move on to next generation 
+	// for (i = 0; i < i_NP; i++) {
+	//     for (j = 0; j < i_D; j++) 
+	// 	ta_oldP.at(i,j) = ta_newP.at(i,j);
+	//     ta_oldC[i] = ta_newC[i];
+	// }
+	ta_oldP = ta_newP;
+	ta_oldC = ta_newC;
+
+	if (i_check_winner)  {		// check if the best stayed the same, if necessary 
 	    same = 1;
 	    for (j = 0; j < i_D; j++)
 		if (t_bestitP[j] != t_bestP[j]) {
 		    same = 0;
 		}
-	    if(same && i_iter > 1)  {
+	    if (same && i_iter > 1)  {
 		i_xav++;
 		tmp_best = evaluate(l_nfeval, t_bestP, par, fcall, rho);			// if re-evaluation of winner 
-
-		/* possibly letting the winner be the average of all past generations */
-		if(i_av_winner)
+		
+		if (i_av_winner)			//  possibly letting the winner be the average of all past generations 
 		    t_bestC = ((1/(double)i_xav) * t_bestC) + ((1/(double)i_xav) * tmp_best) + (d_bestvalit[i_iter-1] * ((double)(i_xav - 2))/(double)i_xav);
 		else
 		    t_bestC = tmp_best;
-	    }
-	    else {
+	    } else {
 		i_xav = 1;
 	    }
 	}
-	for (j = 0; j < i_D; j++) 
-	    t_bestitP[j] = t_bestP[j];
+	// for (j = 0; j < i_D; j++) 
+	//     t_bestitP[j] = t_bestP[j];
+	// t_bestitC = t_bestC;
+	t_bestitP = t_bestP;
 	t_bestitC = t_bestC;
 
-	if( i_trace > 0 ) {
-	    if( (i_iter % i_trace) == 0 ) {
+	if ( i_trace > 0 ) {
+	    if ( (i_iter % i_trace) == 0 ) {
 		Rprintf("Iteration: %d bestvalit: %f bestmemit:", i_iter, t_bestC);
 		for (j = 0; j < i_D; j++)
 		    Rprintf("%12.6f", t_bestP[j]);



More information about the Rcpp-commits mailing list