[Returnanalytics-commits] r2270 - pkg/PortfolioAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 2 00:43:02 CEST 2012


Author: braverock
Date: 2012-09-02 00:43:02 +0200 (Sun, 02 Sep 2012)
New Revision: 2270

Modified:
   pkg/PortfolioAnalytics/R/optimize.portfolio.R
Log:
- additional adjustments to search_siz in DEoptim


Modified: pkg/PortfolioAnalytics/R/optimize.portfolio.R
===================================================================
--- pkg/PortfolioAnalytics/R/optimize.portfolio.R	2012-09-01 21:47:24 UTC (rev 2269)
+++ pkg/PortfolioAnalytics/R/optimize.portfolio.R	2012-09-01 22:43:02 UTC (rev 2270)
@@ -148,6 +148,10 @@
     NP = round(search_size/itermax)
     if(NP<(N*10)) NP <- N*10
     if(NP>2000) NP=2000
+    if(!hasArg(itermax)) {
+        itermax<-round(search_size/NP)
+        if(itermax<50) itermax=50 #set minimum number of generations
+    }
     
     #check to see whether we need to disable foreach for parallel optimization, esp if called from inside foreach
     if(hasArg(parallel)) parallel=match.call(expand.dots=TRUE)$parallel else parallel=TRUE
@@ -371,7 +375,11 @@
       controlPSO[pm] <- dotargs[pm > 0L]
       if(!hasArg(reltol)) controlPSO$reltol <- .000001 # 1/1000 of 1% change in objective is significant
       if(hasArg(trace) && try(trace==TRUE,silent=TRUE)) controlPSO$trace <- TRUE
-    }
+      if(hasArg(trace) && isTRUE(trace)) {
+          controlPSO$trace <- TRUE
+          controlPSO$trace.stats=TRUE
+      }
+  }
     
     # get upper and lower weights parameters from constraints
     upper <- constraints$max



More information about the Returnanalytics-commits mailing list