[Returnanalytics-commits] r3632 - in pkg/PortfolioAnalytics: . R man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Apr 17 18:38:40 CEST 2015


Author: rossbennett34
Date: 2015-04-17 18:38:40 +0200 (Fri, 17 Apr 2015)
New Revision: 3632

Added:
   pkg/PortfolioAnalytics/R/zzz.R
Removed:
   pkg/PortfolioAnalytics/man/pHist.Rd
Modified:
   pkg/PortfolioAnalytics/DESCRIPTION
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/EntropyProg.R
   pkg/PortfolioAnalytics/R/constrained_objective.R
   pkg/PortfolioAnalytics/R/extract.efficient.frontier.R
   pkg/PortfolioAnalytics/R/extractstats.R
   pkg/PortfolioAnalytics/R/moment.functions.R
   pkg/PortfolioAnalytics/R/optFUN.R
   pkg/PortfolioAnalytics/R/optimize.portfolio.R
   pkg/PortfolioAnalytics/R/random_portfolios.R
   pkg/PortfolioAnalytics/man/BlackLittermanFormula.Rd
   pkg/PortfolioAnalytics/man/CCCgarch.MM.Rd
   pkg/PortfolioAnalytics/man/EntropyProg.Rd
   pkg/PortfolioAnalytics/man/HHI.Rd
   pkg/PortfolioAnalytics/man/ac.ranking.Rd
   pkg/PortfolioAnalytics/man/add.constraint.Rd
   pkg/PortfolioAnalytics/man/add.objective.Rd
   pkg/PortfolioAnalytics/man/add.sub.portfolio.Rd
   pkg/PortfolioAnalytics/man/applyFUN.Rd
   pkg/PortfolioAnalytics/man/barplotGroupWeights.Rd
   pkg/PortfolioAnalytics/man/black.litterman.Rd
   pkg/PortfolioAnalytics/man/box_constraint.Rd
   pkg/PortfolioAnalytics/man/center.Rd
   pkg/PortfolioAnalytics/man/centroid.buckets.Rd
   pkg/PortfolioAnalytics/man/centroid.complete.mc.Rd
   pkg/PortfolioAnalytics/man/centroid.sectors.Rd
   pkg/PortfolioAnalytics/man/centroid.sign.Rd
   pkg/PortfolioAnalytics/man/chart.Concentration.Rd
   pkg/PortfolioAnalytics/man/chart.EF.Weights.Rd
   pkg/PortfolioAnalytics/man/chart.EfficientFrontier.Rd
   pkg/PortfolioAnalytics/man/chart.EfficientFrontierOverlay.Rd
   pkg/PortfolioAnalytics/man/chart.GroupWeights.Rd
   pkg/PortfolioAnalytics/man/chart.RiskBudget.Rd
   pkg/PortfolioAnalytics/man/chart.RiskReward.Rd
   pkg/PortfolioAnalytics/man/chart.Weights.Rd
   pkg/PortfolioAnalytics/man/check_constraints.Rd
   pkg/PortfolioAnalytics/man/cokurtosisMF.Rd
   pkg/PortfolioAnalytics/man/cokurtosisSF.Rd
   pkg/PortfolioAnalytics/man/combine.optimizations.Rd
   pkg/PortfolioAnalytics/man/combine.portfolios.Rd
   pkg/PortfolioAnalytics/man/constrained_objective.Rd
   pkg/PortfolioAnalytics/man/constraint.Rd
   pkg/PortfolioAnalytics/man/constraint_ROI.Rd
   pkg/PortfolioAnalytics/man/constraint_v2.Rd
   pkg/PortfolioAnalytics/man/coskewnessMF.Rd
   pkg/PortfolioAnalytics/man/coskewnessSF.Rd
   pkg/PortfolioAnalytics/man/covarianceMF.Rd
   pkg/PortfolioAnalytics/man/covarianceSF.Rd
   pkg/PortfolioAnalytics/man/create.EfficientFrontier.Rd
   pkg/PortfolioAnalytics/man/diversification.Rd
   pkg/PortfolioAnalytics/man/diversification_constraint.Rd
   pkg/PortfolioAnalytics/man/equal.weight.Rd
   pkg/PortfolioAnalytics/man/etl_milp_opt.Rd
   pkg/PortfolioAnalytics/man/etl_opt.Rd
   pkg/PortfolioAnalytics/man/extractCokurtosis.Rd
   pkg/PortfolioAnalytics/man/extractCoskewness.Rd
   pkg/PortfolioAnalytics/man/extractCovariance.Rd
   pkg/PortfolioAnalytics/man/extractEfficientFrontier.Rd
   pkg/PortfolioAnalytics/man/extractGroups.Rd
   pkg/PortfolioAnalytics/man/extractObjectiveMeasures.Rd
   pkg/PortfolioAnalytics/man/extractStats.Rd
   pkg/PortfolioAnalytics/man/extractWeights.Rd
   pkg/PortfolioAnalytics/man/factor_exposure_constraint.Rd
   pkg/PortfolioAnalytics/man/fn_map.Rd
   pkg/PortfolioAnalytics/man/generatesequence.Rd
   pkg/PortfolioAnalytics/man/get_constraints.Rd
   pkg/PortfolioAnalytics/man/gmv_opt.Rd
   pkg/PortfolioAnalytics/man/gmv_opt_leverage.Rd
   pkg/PortfolioAnalytics/man/gmv_opt_ptc.Rd
   pkg/PortfolioAnalytics/man/gmv_opt_toc.Rd
   pkg/PortfolioAnalytics/man/group_constraint.Rd
   pkg/PortfolioAnalytics/man/group_fail.Rd
   pkg/PortfolioAnalytics/man/insert_constraints.Rd
   pkg/PortfolioAnalytics/man/insert_objectives.Rd
   pkg/PortfolioAnalytics/man/inverse.volatility.weight.Rd
   pkg/PortfolioAnalytics/man/is.constraint.Rd
   pkg/PortfolioAnalytics/man/is.objective.Rd
   pkg/PortfolioAnalytics/man/is.portfolio.Rd
   pkg/PortfolioAnalytics/man/leverage_exposure_constraint.Rd
   pkg/PortfolioAnalytics/man/maxret_milp_opt.Rd
   pkg/PortfolioAnalytics/man/maxret_opt.Rd
   pkg/PortfolioAnalytics/man/meanetl.efficient.frontier.Rd
   pkg/PortfolioAnalytics/man/meanvar.efficient.frontier.Rd
   pkg/PortfolioAnalytics/man/meucci.moments.Rd
   pkg/PortfolioAnalytics/man/meucci.ranking.Rd
   pkg/PortfolioAnalytics/man/minmax_objective.Rd
   pkg/PortfolioAnalytics/man/mult.portfolio.spec.Rd
   pkg/PortfolioAnalytics/man/name.replace.Rd
   pkg/PortfolioAnalytics/man/objective.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio.parallel.Rd
   pkg/PortfolioAnalytics/man/optimize.portfolio.rebalancing.Rd
   pkg/PortfolioAnalytics/man/plot.Rd
   pkg/PortfolioAnalytics/man/portfolio.moments.bl.Rd
   pkg/PortfolioAnalytics/man/portfolio.moments.boudt.Rd
   pkg/PortfolioAnalytics/man/portfolio.spec.Rd
   pkg/PortfolioAnalytics/man/portfolio_risk_objective.Rd
   pkg/PortfolioAnalytics/man/pos_limit_fail.Rd
   pkg/PortfolioAnalytics/man/position_limit_constraint.Rd
   pkg/PortfolioAnalytics/man/print.constraint.Rd
   pkg/PortfolioAnalytics/man/print.efficient.frontier.Rd
   pkg/PortfolioAnalytics/man/print.optimize.portfolio.Rd
   pkg/PortfolioAnalytics/man/print.optimize.portfolio.rebalancing.Rd
   pkg/PortfolioAnalytics/man/print.portfolio.Rd
   pkg/PortfolioAnalytics/man/print.summary.optimize.portfolio.Rd
   pkg/PortfolioAnalytics/man/print.summary.optimize.portfolio.rebalancing.Rd
   pkg/PortfolioAnalytics/man/quadratic_utility_objective.Rd
   pkg/PortfolioAnalytics/man/random_portfolios.Rd
   pkg/PortfolioAnalytics/man/random_portfolios_v1.Rd
   pkg/PortfolioAnalytics/man/random_walk_portfolios.Rd
   pkg/PortfolioAnalytics/man/randomize_portfolio.Rd
   pkg/PortfolioAnalytics/man/randomize_portfolio_v1.Rd
   pkg/PortfolioAnalytics/man/regime.portfolios.Rd
   pkg/PortfolioAnalytics/man/return_constraint.Rd
   pkg/PortfolioAnalytics/man/return_objective.Rd
   pkg/PortfolioAnalytics/man/risk_budget_objective.Rd
   pkg/PortfolioAnalytics/man/rp_grid.Rd
   pkg/PortfolioAnalytics/man/rp_sample.Rd
   pkg/PortfolioAnalytics/man/rp_simplex.Rd
   pkg/PortfolioAnalytics/man/rp_transform.Rd
   pkg/PortfolioAnalytics/man/scatterFUN.Rd
   pkg/PortfolioAnalytics/man/set.portfolio.moments.Rd
   pkg/PortfolioAnalytics/man/set.portfolio.moments_v1.Rd
   pkg/PortfolioAnalytics/man/statistical.factor.model.Rd
   pkg/PortfolioAnalytics/man/summary.efficient.frontier.Rd
   pkg/PortfolioAnalytics/man/summary.optimize.portfolio.Rd
   pkg/PortfolioAnalytics/man/summary.optimize.portfolio.rebalancing.Rd
   pkg/PortfolioAnalytics/man/summary.portfolio.Rd
   pkg/PortfolioAnalytics/man/trailingFUN.Rd
   pkg/PortfolioAnalytics/man/transaction_cost_constraint.Rd
   pkg/PortfolioAnalytics/man/turnover.Rd
   pkg/PortfolioAnalytics/man/turnover_constraint.Rd
   pkg/PortfolioAnalytics/man/turnover_objective.Rd
   pkg/PortfolioAnalytics/man/update.constraint.Rd
   pkg/PortfolioAnalytics/man/update_constraint_v1tov2.Rd
   pkg/PortfolioAnalytics/man/var.portfolio.Rd
   pkg/PortfolioAnalytics/man/weight_concentration_objective.Rd
   pkg/PortfolioAnalytics/man/weight_sum_constraint.Rd
   pkg/PortfolioAnalytics/vignettes/ROI_vignette.Rnw
   pkg/PortfolioAnalytics/vignettes/custom_moments_objectives.Rnw
   pkg/PortfolioAnalytics/vignettes/risk_budget_optimization.Rnw
Log:
Code and documentation cleanup for R CMD check --as-cran

Modified: pkg/PortfolioAnalytics/DESCRIPTION
===================================================================
--- pkg/PortfolioAnalytics/DESCRIPTION	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/DESCRIPTION	2015-04-17 16:38:40 UTC (rev 3632)
@@ -3,27 +3,28 @@
 Title: Portfolio Analysis, including Numerical Methods for Optimization
     of Portfolios
 Authors at R: c(
-  person(given=c("Brian","G."),family="Peterson",role=c("cre","aut","cph"), email="brian at braverock.com")
-  , person(given="Peter",family="Carl",role=c("aut","cph"), email="peter at braverock.com")
-  , person(given="Kris",family="Boudt",role=c("ctb","cph"))
-  , person(given="Ross",family="Bennett",role=c("ctb","cph"))
-  , person(given="Hezky",family="Varon",role="ctb")
-  , person(given="Guy",family="Yollin",role="ctb")
-  , person(given="R. Douglas",family="Martin",role="ctb")
-  )
+    person(given=c("Brian","G."),family="Peterson",role=c("cre","aut","cph"),
+    email="brian at braverock.com") ,
+    person(given="Peter",family="Carl",role=c("aut","cph"),
+    email="peter at braverock.com") ,
+    person(given="Kris",family="Boudt",role=c("ctb","cph")) ,
+    person(given="Ross",family="Bennett",role=c("ctb","cph")) ,
+    person(given="Hezky",family="Varon",role="ctb") ,
+    person(given="Guy",family="Yollin",role="ctb") ,
+    person(given="R. Douglas",family="Martin",role="ctb") )
 Version: 0.9.3625
 Date: $Date$
-Maintainer: Brian G. Peterson <brian at braverock.com>
+Maintainer: Ross Bennett <rossbennett34 at gmail.com>
 Description: Portfolio optimization and analysis routines and graphics.
 Depends:
     R (>= 2.14.0),
     zoo,
     xts (>= 0.8),
+    foreach,
     PerformanceAnalytics (>= 1.1.0)
 Suggests:
     quantmod,
     DEoptim(>= 2.2.1),
-    foreach,
     iterators,
     fGarch,
     Rglpk,
@@ -36,6 +37,8 @@
     GenSA,
     corpcor,
     testthat,
-    nloptr (>= 1.0.0)
+    nloptr (>= 1.0.0),
+    MASS,
+    robustbase
 License: GPL
 Copyright: (c) 2004-2015

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/NAMESPACE	2015-04-17 16:38:40 UTC (rev 3632)
@@ -1,5 +1,7 @@
-# Generated by roxygen2 (4.1.0): do not edit by hand
+# Generated by roxygen2 (4.0.1): do not edit by hand
 
+S3method(chart.EF.Weights,efficient.frontier)
+S3method(chart.EF.Weights,optimize.portfolio)
 S3method(chart.EfficientFrontier,efficient.frontier)
 S3method(chart.EfficientFrontier,optimize.portfolio)
 S3method(chart.EfficientFrontier,optimize.portfolio.ROI)
@@ -19,8 +21,6 @@
 S3method(chart.Weights,optimize.portfolio.pso)
 S3method(chart.Weights,optimize.portfolio.random)
 S3method(chart.Weights,optimize.portfolio.rebalancing)
-S3method(chart.EF.Weights,efficient.frontier)
-S3method(chart.EF.Weights,optimize.portfolio)
 S3method(extractObjectiveMeasures,opt.list)
 S3method(extractObjectiveMeasures,opt.rebal.list)
 S3method(extractObjectiveMeasures,optimize.portfolio)
@@ -88,13 +88,13 @@
 export(centroid.sectors)
 export(centroid.sign)
 export(chart.Concentration)
+export(chart.EF.Weights)
 export(chart.EfficientFrontier)
 export(chart.EfficientFrontierOverlay)
 export(chart.GroupWeights)
 export(chart.RiskBudget)
 export(chart.RiskReward)
 export(chart.Weights)
-export(chart.EF.Weights)
 export(combine.optimizations)
 export(combine.portfolios)
 export(constrained_objective)
@@ -169,4 +169,8 @@
 export(var.portfolio)
 export(weight_concentration_objective)
 export(weight_sum_constraint)
+import(PerformanceAnalytics)
+import(foreach)
+import(xts)
+import(zoo)
 useDynLib("PortfolioAnalytics")

Modified: pkg/PortfolioAnalytics/R/EntropyProg.R
===================================================================
--- pkg/PortfolioAnalytics/R/EntropyProg.R	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/R/EntropyProg.R	2015-04-17 16:38:40 UTC (rev 3632)
@@ -49,7 +49,7 @@
 #' @export
 EntropyProg = function( p , A = NULL , b = NULL , Aeq , beq, verbose=FALSE )
 {
-  stopifnot("package:nloptr" %in% search()  ||  require("nloptr",quietly = TRUE) )
+  stopifnot("package:nloptr" %in% search()  ||  requireNamespace("nloptr",quietly = TRUE) )
   
   if( is.vector(b) ) b = matrix(b, nrow=length(b))
   if( is.vector(beq) ) beq = matrix(beq, nrow=length(beq))
@@ -119,7 +119,7 @@
                  check_derivatives_print = check_derivatives_print , 
                  print_level = print_level , 
                  maxeval = 1000 )    
-    optimResult = nloptr(x0 = x0, eval_f = eval_f_list , opts = opts )    
+    optimResult = nloptr::nloptr(x0 = x0, eval_f = eval_f_list , opts = opts )    
     end = Sys.time()
     
     if(verbose){
@@ -189,7 +189,7 @@
                         eval_f = nestedfunC , 
                         eval_g_ineq = InqConstraint , 
                         eval_jac_g_ineq = jacobian_constraint )
-    optimResult = nloptr( x0 = x0 , 
+    optimResult = nloptr::nloptr( x0 = x0 , 
                           eval_f = nestedfunC , 
                           eval_g_ineq = InqConstraint , 
                           eval_jac_g_ineq = jacobian_constraint ,

Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R	2015-04-17 16:38:40 UTC (rev 3632)
@@ -382,7 +382,7 @@
   store_output <- try(get('.objectivestorage',envir=.storage), silent=TRUE)
   if(inherits(store_output,"try-error")) {
     storage <- FALSE
-    warning("could not get .objectivestorage")
+    # warning("could not get .objectivestorage")
   } else {
     storage <- TRUE
   }

Modified: pkg/PortfolioAnalytics/R/extract.efficient.frontier.R
===================================================================
--- pkg/PortfolioAnalytics/R/extract.efficient.frontier.R	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/R/extract.efficient.frontier.R	2015-04-17 16:38:40 UTC (rev 3632)
@@ -31,10 +31,10 @@
   columnnames=colnames(xtract)
   # optimal portfolio stats from xtract
   opt <- xtract[which.min(xtract[, "out"]),]
-  #if("package:multicore" %in% search() || require("multicore",quietly = TRUE)){
+  #if("package:multicore" %in% search() || requireNamespace("multicore",quietly = TRUE)){
   #    mclapply
   #}
-  stopifnot("package:foreach" %in% search() || require("foreach",quietly = TRUE))
+  stopifnot("package:foreach" %in% search() || requireNamespace("foreach",quietly = TRUE))
   #    rtc = pmatch(return.col,columnnames)
   #    if(is.na(rtc)) {
   #        rtc = pmatch(paste(return.col,return.col,sep='.'),columnnames)
@@ -61,7 +61,7 @@
   
   set<-cbind(quantmod::Lag(set,1),as.matrix(set))[-1,]
   i <- 1
-  result <- foreach(i=1:nrow(set),.inorder=TRUE, .combine=rbind, .errorhandling='remove') %do% {
+  result <- foreach::foreach(i=1:nrow(set),.inorder=TRUE, .combine=rbind, .errorhandling='remove') %do% {
     tmp<-xtract[which(xtract[,mtc]>=set[i,1] & xtract[,mtc]<set[i,2]),]
     #tmp<-tmp[which.min(tmp[,'out']),]
     tmp<-tmp[which.max(tmp[,'mean']),]
@@ -170,13 +170,13 @@
   portfolio <- add.constraint(portfolio=portfolio, type="return", return_target=minret, enabled=FALSE)
   ret_constr_idx <- which(unlist(lapply(portfolio$constraints, function(x) inherits(x, "return_constraint"))))
   
-  stopifnot("package:foreach" %in% search() || require("foreach",quietly = TRUE))
-  stopifnot("package:iterators" %in% search() || require("iterators",quietly = TRUE))
+  stopifnot("package:foreach" %in% search() || requireNamespace("foreach",quietly = TRUE))
+  stopifnot("package:iterators" %in% search() || requireNamespace("iterators",quietly = TRUE))
   if(!is.null(risk_aversion)){
     # Enable the return objective so we are doing quadratic utility
     portfolio$objectives[[mean_idx]]$enabled <- TRUE
     lambda <- risk_aversion[1]
-    out <- foreach(lambda=iter(risk_aversion), .inorder=TRUE, .combine=rbind, .errorhandling='remove', .packages='PortfolioAnalytics') %dopar% {
+    out <- foreach::foreach(lambda=iterators::iter(risk_aversion), .inorder=TRUE, .combine=rbind, .errorhandling='remove', .packages='PortfolioAnalytics') %dopar% {
       portfolio$objectives[[var_idx]]$risk_aversion <- lambda
       extractStats(optimize.portfolio(R=R, portfolio=portfolio, optimize_method="ROI", ...=...))
     }
@@ -186,7 +186,7 @@
     # Enable the return constraint
     portfolio$constraints[[ret_constr_idx]]$enabled <- TRUE
     ret <- ret_seq[1]
-    out <- foreach(ret=iter(ret_seq), .inorder=TRUE, .combine=rbind, .errorhandling='remove', .packages='PortfolioAnalytics') %dopar% {
+    out <- foreach::foreach(ret=iterators::iter(ret_seq), .inorder=TRUE, .combine=rbind, .errorhandling='remove', .packages='PortfolioAnalytics') %dopar% {
       portfolio$constraints[[ret_constr_idx]]$return_target <- ret
       opt <- optimize.portfolio(R=R, portfolio=portfolio, optimize_method="ROI", ...=...)
       c(sum(extractWeights(opt) * mean_ret), extractStats(opt))
@@ -271,10 +271,10 @@
   #     portfolio$objectives[[mean_idx]]$target <- ret_seq[i]
   #     out[i, ] <- extractStats(optimize.portfolio(R=R, portfolio=portfolio, optimize_method="ROI"))
   #   }
-  stopifnot("package:foreach" %in% search() || require("foreach",quietly = TRUE))
-  stopifnot("package:iterators" %in% search() || require("iterators",quietly = TRUE))
+  stopifnot("package:foreach" %in% search() || requireNamespace("foreach",quietly = TRUE))
+  stopifnot("package:iterators" %in% search() || requireNamespace("iterators",quietly = TRUE))
   ret <- ret_seq[1]
-  out <- foreach(ret=iter(ret_seq), .inorder=TRUE, .combine=rbind, .errorhandling='remove', .packages='PortfolioAnalytics') %dopar% {
+  out <- foreach::foreach(ret=iterators::iter(ret_seq), .inorder=TRUE, .combine=rbind, .errorhandling='remove', .packages='PortfolioAnalytics') %dopar% {
     portfolio$objectives[[mean_idx]]$target <- ret
     extractStats(optimize.portfolio(R=R, portfolio=portfolio, optimize_method="ROI", ef=TRUE, ...=...))
   }

Modified: pkg/PortfolioAnalytics/R/extractstats.R
===================================================================
--- pkg/PortfolioAnalytics/R/extractstats.R	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/R/extractstats.R	2015-04-17 16:38:40 UTC (rev 3632)
@@ -190,9 +190,9 @@
   tmpout <- c(object$out, tmpout)
   
   # run constrained_objective on the weights to get the objective measures in a matrix
-  stopifnot("package:foreach" %in% search() || suppressMessages(require("foreach",quietly = TRUE)))
+  stopifnot("package:foreach" %in% search() || suppressMessages(requireNamespace("foreach",quietly = TRUE)))
   i <- 1
-  obj <- foreach(i=1:nrow(psoweights), .inorder=TRUE, .combine=rbind, .errorhandling='remove') %dopar% {
+  obj <- foreach::foreach(i=1:nrow(psoweights), .inorder=TRUE, .combine=rbind, .errorhandling='remove') %dopar% {
     unlist(constrained_objective(w=psoweights[i,], R=R, portfolio=portfolio, trace=TRUE)$objective_measures)
   }
   objnames <- name.replace(colnames(obj))

Modified: pkg/PortfolioAnalytics/R/moment.functions.R
===================================================================
--- pkg/PortfolioAnalytics/R/moment.functions.R	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/R/moment.functions.R	2015-04-17 16:38:40 UTC (rev 3632)
@@ -21,7 +21,7 @@
 #' @export
 CCCgarch.MM = function(R, momentargs = NULL , ... )
 {
-  stopifnot("package:fGarch" %in% search() || require("fGarch",quietly=TRUE))
+  stopifnot("package:fGarch" %in% search() || requireNamespace("fGarch",quietly=TRUE))
   if (!hasArg(momentargs) | is.null(momentargs)) 
     momentargs <- list()
   cAssets = ncol(R)
@@ -33,7 +33,7 @@
   momentargs$mu = mu
   S = nextS = c();
   for( i in 1:cAssets ){
-    gout =  garchFit(formula ~ garch(1,1), data = R[,i],include.mean = F, cond.dist="QMLE", trace = FALSE )
+    gout =  fGarch::garchFit(formula ~ garch(1,1), data = R[,i],include.mean = F, cond.dist="QMLE", trace = FALSE )
     if( as.vector(gout at fit$coef["alpha1"]) < 0.01 ){
       sigmat = rep( sd( as.vector(R[,i])), length(R[,i]) ); nextSt = sd( as.vector(R[,i]))
     }else{

Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/R/optFUN.R	2015-04-17 16:38:40 UTC (rev 3632)
@@ -16,9 +16,9 @@
 #' @param control list of solver control parameters
 #' @author Ross Bennett
 gmv_opt <- function(R, constraints, moments, lambda, target, lambda_hhi, conc_groups, solver="quadprog", control=NULL){
-  stopifnot("package:ROI" %in% search() || require("ROI", quietly=TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI", quietly=TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -62,7 +62,7 @@
   lb <- constraints$min
   ub <- constraints$max
   
-  bnds <- V_bound(li=seq.int(1L, N), lb=as.numeric(lb),
+  bnds <- ROI::V_bound(li=seq.int(1L, N), lb=as.numeric(lb),
                   ui=seq.int(1L, N), ub=as.numeric(ub))
   
   # Include group constraints
@@ -102,7 +102,7 @@
   # Set up the quadratic objective
   if(!is.null(lambda_hhi)){
     if(length(lambda_hhi) == 1 & is.null(conc_groups)){
-      ROI_objective <- Q_objective(Q=2*lambda*(moments$var + lambda_hhi * diag(N)), L=-moments$mean) # ROI
+      ROI_objective <- ROI::Q_objective(Q=2*lambda*(moments$var + lambda_hhi * diag(N)), L=-moments$mean) # ROI
       #Dmat <- 2*lambda*(moments$var + lambda_hhi * diag(N)) # solve.QP
       #dvec <- moments$mean # solve.QP
     } else if(!is.null(conc_groups)){
@@ -118,20 +118,20 @@
         }
         hhi_mat <- hhi_mat + lambda_hhi[i] * tmpI
       }
-      ROI_objective <- Q_objective(Q=2*lambda*(moments$var + hhi_mat), L=-moments$mean) # ROI
+      ROI_objective <- ROI::Q_objective(Q=2*lambda*(moments$var + hhi_mat), L=-moments$mean) # ROI
       #Dmat <- 2 * lambda * (moments$var + hhi_mat) # solve.QP
       #dvec <- moments$mean # solve.QP
     }
   } else {
-    ROI_objective <- Q_objective(Q=2*lambda*moments$var, L=-moments$mean) # ROI
+    ROI_objective <- ROI::Q_objective(Q=2*lambda*moments$var, L=-moments$mean) # ROI
     #Dmat <- 2 * lambda * moments$var # solve.QP
     #dvec <- moments$mean # solve.QP
   }
   # set up the optimization problem and solve
-  opt.prob <- OP(objective=ROI_objective, 
-                       constraints=L_constraint(L=Amat, dir=dir.vec, rhs=rhs.vec),
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                       constraints=ROI::L_constraint(L=Amat, dir=dir.vec, rhs=rhs.vec),
                  bounds=bnds)
-  result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   
   # result <- try(solve.QP(Dmat=Dmat, dvec=dvec, Amat=t(Amat), bvec=rhs.vec, meq=meq), silent=TRUE)
   if(inherits(x=result, "try-error")) stop(paste("No solution found:", result))
@@ -178,9 +178,9 @@
 #' @param control list of solver control parameters
 #' @author Ross Bennett
 maxret_opt <- function(R, moments, constraints, target, solver="glpk", control=NULL){
-  stopifnot("package:ROI" %in% search() || require("ROI",quietly = TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI",quietly = TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -196,7 +196,7 @@
     ub[is.infinite(ub)] <- max(abs(c(constraints$min_sum, constraints$max_sum)))
     lb[is.infinite(lb)] <- 0
   }
-  bnds <- V_bound(li=seq.int(1L, N), lb=as.numeric(lb),
+  bnds <- ROI::V_bound(li=seq.int(1L, N), lb=as.numeric(lb),
                   ui=seq.int(1L, N), ub=as.numeric(ub))
   
   # set up initial A matrix for leverage constraints
@@ -234,14 +234,14 @@
   }
   
   # set up the linear objective
-  ROI_objective <- L_objective(L=-moments$mean)
+  ROI_objective <- ROI::L_objective(L=-moments$mean)
   # objL <- -moments$mean
   
   # set up the optimization problem and solve
-  opt.prob <- OP(objective=ROI_objective, 
-                 constraints=L_constraint(L=Amat, dir=dir.vec, rhs=rhs.vec),
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                 constraints=ROI::L_constraint(L=Amat, dir=dir.vec, rhs=rhs.vec),
                  bounds=bnds)
-  roi.result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  roi.result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   if(inherits(roi.result, "try-error")) stop(paste("No solution found:", roi.result))
   
   # roi.result <- Rglpk_solve_LP(obj=objL, mat=Amat, dir=dir.vec, rhs=rhs.vec, bounds=bnds)
@@ -286,9 +286,9 @@
 #' @param control list of solver control parameters
 #' @author Ross Bennett
 maxret_milp_opt <- function(R, constraints, moments, target, solver="glpk", control=NULL){
-  stopifnot("package:ROI" %in% search() || require("ROI",quietly = TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI",quietly = TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -364,7 +364,7 @@
   }
   
   # Only seems to work if I do not specify bounds
-  # bnds <- V_bound(li=seq.int(1L, 2*m), lb=c(as.numeric(constraints$min), rep(0, m)),
+  # bnds <- ROI::V_Bound(li=seq.int(1L, 2*m), lb=c(as.numeric(constraints$min), rep(0, m)),
   #                 ui=seq.int(1L, 2*m), ub=c(as.numeric(constraints$max), rep(1, m)))
   bnds <- NULL
   
@@ -372,13 +372,13 @@
   types <- c(rep("C", N), rep("B", N))
   
   # Set up the linear objective to maximize mean return
-  ROI_objective <- L_objective(L=c(-moments$mean, rep(0, N)))
+  ROI_objective <- ROI::L_objective(L=c(-moments$mean, rep(0, N)))
   
   # Set up the optimization problem and solve
-  opt.prob <- OP(objective=ROI_objective, 
-                 constraints=L_constraint(L=Amat, dir=dir, rhs=rhs),
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                 constraints=ROI::L_constraint(L=Amat, dir=dir, rhs=rhs),
                  bounds=bnds, types=types)
-  roi.result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  roi.result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   if(inherits(roi.result, "try-error")) stop(paste("No solution found:", roi.result))
   
   # Weights
@@ -412,9 +412,9 @@
 #' @param control list of solver control parameters
 #' @author Ross Bennett
 etl_opt <- function(R, constraints, moments, target, alpha, solver="glpk", control=NULL){
-  stopifnot("package:ROI" %in% search() || require("ROI",quietly = TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI",quietly = TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -424,7 +424,7 @@
   # Applying box constraints
   LB <- c(as.numeric(constraints$min), rep(0, T), -1)
   UB <- c(as.numeric(constraints$max), rep(Inf, T), 1)
-  bnds <- V_bound(li=seq.int(1L, N+T+1), lb=LB,
+  bnds <- ROI::V_bound(li=seq.int(1L, N+T+1), lb=LB,
                   ui=seq.int(1L, N+T+1), ub=UB)
   
   # Add this check if mean is not an objective and return is a constraints
@@ -463,11 +463,11 @@
     rhs.vec <- c(rhs.vec, constraints$lower, -constraints$upper)
   }
   
-  ROI_objective <- L_objective(c(rep(0,N), rep(1/(alpha*T),T), 1))
-  opt.prob <- OP(objective=ROI_objective, 
-                       constraints=L_constraint(L=Amat, dir=dir.vec, rhs=rhs.vec),
+  ROI_objective <- ROI::L_objective(c(rep(0,N), rep(1/(alpha*T),T), 1))
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                       constraints=ROI::L_constraint(L=Amat, dir=dir.vec, rhs=rhs.vec),
                        bounds=bnds)
-  roi.result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  roi.result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   if(inherits(x=roi.result, "try-error")) stop(paste("No solution found:", roi.result))
   
   weights <- roi.result$solution[1:N]
@@ -512,9 +512,9 @@
 #' @param control list of solver control parameters
 #' @author Ross Bennett
 etl_milp_opt <- function(R, constraints, moments, target, alpha, solver="glpk", control=NULL){
-  stopifnot("package:ROI" %in% search() || require("ROI",quietly = TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI",quietly = TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -606,19 +606,19 @@
   }
   
   # Linear objective vector
-  ROI_objective <- L_objective(c( rep(0, m), 1, rep(1/n, n) / alpha, 0, rep(0, m)))
+  ROI_objective <- ROI::L_objective(c( rep(0, m), 1, rep(1/n, n) / alpha, 0, rep(0, m)))
   
   # Set up the types vector with continuous and binary variables
   types <- c( rep("C", m), "C", rep("C", n), "C", rep("B", m))
   
-  bnds <- V_bound( li = 1L:(m + n + 2 + m), lb = c(LB, -1, rep(0, n), 1, rep(0, m)),
+  bnds <- ROI::V_bound( li = 1L:(m + n + 2 + m), lb = c(LB, -1, rep(0, n), 1, rep(0, m)),
                    ui = 1L:(m + n + 2 + m), ub = c(UB, 1, rep(Inf, n), 1, rep(1, m)))
   
   # Set up the optimization problem and solve  
-  opt.prob <- OP(objective=ROI_objective, 
-                 constraints=L_constraint(L=tmpAmat, dir=dir, rhs=rhs),
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                 constraints=ROI::L_constraint(L=tmpAmat, dir=dir, rhs=rhs),
                  bounds=bnds, types=types)
-  roi.result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  roi.result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   if(inherits(roi.result, "try-error")) stop(paste("No solution found:", roi.result))
   
   # The Rglpk solvers status returns an an integer with status information
@@ -672,10 +672,10 @@
 #' @author Ross Bennett
 gmv_opt_toc <- function(R, constraints, moments, lambda, target, init_weights, solver="quadprog", control=NULL){
   # function for minimum variance or max quadratic utility problems
-  stopifnot("package:corpcor" %in% search() || require("corpcor",quietly = TRUE))
-  stopifnot("package:ROI" %in% search() || require("ROI", quietly = TRUE))
+  stopifnot("package:corpcor" %in% search() || requireNamespace("corpcor",quietly = TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI", quietly = TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -776,13 +776,13 @@
   rhs <- rhs[!is.infinite(rhs)]
   dir <- dir[!is.infinite(rhs)]
   
-  ROI_objective <- Q_objective(Q=make.positive.definite(2*lambda*V), 
+  ROI_objective <- ROI::Q_objective(Q=corpcor::make.positive.definite(2*lambda*V), 
                                L=rep(-tmp_means, 3))
   
-  opt.prob <- OP(objective=ROI_objective, 
-                 constraints=L_constraint(L=Amat, dir=dir, rhs=rhs))
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                 constraints=ROI::L_constraint(L=Amat, dir=dir, rhs=rhs))
   
-  roi.result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  roi.result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   if(inherits(roi.result, "try-error")) stop(paste("No solution found:", roi.result))
   
   wts <- roi.result$solution
@@ -832,10 +832,10 @@
 gmv_opt_ptc <- function(R, constraints, moments, lambda, target, init_weights, solver="quadprog", control=NULL){
   # function for minimum variance or max quadratic utility problems
   # modifying ProportionalCostOpt function from MPO package
-  stopifnot("package:corpcor" %in% search() || require("corpcor", quietly = TRUE))
-  stopifnot("package:ROI" %in% search() || require("ROI", quietly = TRUE))
+  stopifnot("package:corpcor" %in% search() || requireNamespace("corpcor", quietly = TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI", quietly = TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -944,11 +944,11 @@
   rhs <- rhs[!is.infinite(rhs)]
   dir <- dir[!is.infinite(rhs)]
   
-  ROI_objective <- Q_objective(Q=make.positive.definite(2*lambda*V), L=d)
+  ROI_objective <- ROI::Q_objective(Q=corpcor::make.positive.definite(2*lambda*V), L=d)
   
-  opt.prob <- OP(objective=ROI_objective, 
-                 constraints=L_constraint(L=Amat, dir=dir, rhs=rhs))
-  roi.result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                 constraints=ROI::L_constraint(L=Amat, dir=dir, rhs=rhs))
+  roi.result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   if(inherits(roi.result, "try-error")) stop(paste("No solution found:", roi.result))
   
   wts <- roi.result$solution
@@ -994,10 +994,10 @@
 #' @author Ross Bennett
 gmv_opt_leverage <- function(R, constraints, moments, lambda, target, solver="quadprog", control=NULL){
   # function for minimum variance or max quadratic utility problems
-  stopifnot("package:corpcor" %in% search() || require("corpcor",quietly = TRUE))
-  stopifnot("package:ROI" %in% search() || require("ROI", quietly = TRUE))
+  stopifnot("package:corpcor" %in% search() || requireNamespace("corpcor",quietly = TRUE))
+  stopifnot("package:ROI" %in% search() || requireNamespace("ROI", quietly = TRUE))
   plugin <- paste0("ROI.plugin.", solver)
-  stopifnot(paste0("package:", plugin) %in% search() || require(plugin, quietly=TRUE, character.only=TRUE))
+  stopifnot(paste0("package:", plugin) %in% search() || requireNamespace(plugin, quietly=TRUE))
   
   # Check for cleaned returns in moments
   if(!is.null(moments$cleanR)) R <- moments$cleanR
@@ -1096,13 +1096,13 @@
   rhs <- rhs[!is.infinite(rhs)]
   dir <- dir[!is.infinite(rhs)]
   
-  ROI_objective <- Q_objective(Q=make.positive.definite(2*lambda*V), 
+  ROI_objective <- ROI::Q_objective(Q=corpcor::make.positive.definite(2*lambda*V), 
                                L=rep(-tmp_means, 3))
   
-  opt.prob <- OP(objective=ROI_objective, 
-                 constraints=L_constraint(L=Amat, dir=dir, rhs=rhs))
+  opt.prob <- ROI::OP(objective=ROI_objective, 
+                 constraints=ROI::L_constraint(L=Amat, dir=dir, rhs=rhs))
   
-  roi.result <- try(ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
+  roi.result <- try(ROI::ROI_solve(x=opt.prob, solver=solver, control=control), silent=TRUE)
   if(inherits(roi.result, "try-error")) stop(paste("No solution found:", roi.result))
   
   wts <- roi.result$solution

Modified: pkg/PortfolioAnalytics/R/optimize.portfolio.R
===================================================================
--- pkg/PortfolioAnalytics/R/optimize.portfolio.R	2015-04-17 00:32:48 UTC (rev 3631)
+++ pkg/PortfolioAnalytics/R/optimize.portfolio.R	2015-04-17 16:38:40 UTC (rev 3632)
@@ -90,7 +90,7 @@
   }
   
   if(optimize_method=="DEoptim"){
-    stopifnot("package:DEoptim" %in% search()  ||  require("DEoptim",quietly = TRUE) )
+    stopifnot("package:DEoptim" %in% search()  ||  requireNamespace("DEoptim",quietly = TRUE) )
     # DEoptim does 200 generations by default, so lets set the size of each generation to search_size/200)
     if(hasArg(itermax)) itermax=match.call(expand.dots=TRUE)$itermax else itermax=N*50
     NP = round(search_size/itermax)
@@ -104,10 +104,10 @@
     #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
     if(!isTRUE(parallel) && 'package:foreach' %in% search()){
-        registerDoSEQ()
+        foreach::registerDoSEQ()
     }
     
-    DEcformals  <- formals(DEoptim.control)
+    DEcformals  <- formals(DEoptim::DEoptim.control)
     DEcargs <- names(DEcformals)
     if( is.list(dotargs) ){
         pm <- pmatch(names(dotargs), DEcargs, nomatch = 0L)
@@ -181,10 +181,10 @@
     	rp <- random_portfolios_v1(rpconstraints=rpconstraint,permutations=NP)
     	DEcformals$initialpop=rp
     }
-    controlDE <- do.call(DEoptim.control,DEcformals)
+    controlDE <- do.call(DEoptim::DEoptim.control,DEcformals)
 
     # minw = try(DEoptim( constrained_objective ,  lower = lower[1:N] , upper = upper[1:N] , control = controlDE, R=R, constraints=constraints, ...=...)) # add ,silent=TRUE here?
-    minw = try(DEoptim( constrained_objective_v1 ,  lower = lower[1:N] , upper = upper[1:N] , control = controlDE, R=R, constraints=constraints, nargs = dotargs , ...=...)) # add ,silent=TRUE here?
+    minw = try(DEoptim::DEoptim( constrained_objective_v1 ,  lower = lower[1:N] , upper = upper[1:N] , control = controlDE, R=R, constraints=constraints, nargs = dotargs , ...=...)) # add ,silent=TRUE here?
  
     if(inherits(minw,"try-error")) { minw=NULL }
     if(is.null(minw)){
@@ -218,7 +218,7 @@
       #' write foreach loop to call constrained_objective() with each portfolio
       if ("package:foreach" %in% search() & !hasArg(parallel)){
           ii <- 1
-          rp_objective_results<-foreach(ii=1:nrow(rp), .errorhandling='pass') %dopar% constrained_objective_v1(w=rp[ii,],R,constraints,trace=trace,...=dotargs)
+          rp_objective_results<-foreach::foreach(ii=1:nrow(rp), .errorhandling='pass') %dopar% constrained_objective_v1(w=rp[ii,],R,constraints,trace=trace,...=dotargs)
       } else {
           rp_objective_results<-apply(rp, 1, constrained_objective_v1, R=R, constraints=constraints, trace=trace, ...=dotargs)
       }
@@ -351,7 +351,7 @@
   
   ## case if method=pso---particle swarm
   if(optimize_method=="pso"){
-    stopifnot("package:pso" %in% search()  ||  require("pso",quietly = TRUE) )
+    stopifnot("package:pso" %in% search()  ||  requireNamespace("pso",quietly = TRUE) )
     if(hasArg(maxit)) maxit=match.call(expand.dots=TRUE)$maxit else maxit=N*50
     controlPSO <- list(trace=FALSE, fnscale=1, maxit=1000, maxf=Inf, abstol=-Inf, reltol=0)
     PSOcargs <- names(controlPSO)
@@ -385,7 +385,7 @@
     upper <- constraints$max
     lower <- constraints$min
     
-    minw = try(psoptim( par = rep(NA, N), fn = constrained_objective_v1 ,  R=R, constraints=constraints,
+    minw = try(pso::psoptim( par = rep(NA, N), fn = constrained_objective_v1 ,  R=R, constraints=constraints,
                         lower = lower[1:N] , upper = upper[1:N] , control = controlPSO)) # add ,silent=TRUE here?
     
     if(inherits(minw,"try-error")) { minw=NULL }
@@ -411,7 +411,7 @@
   
   ## case if method=GenSA---Generalized Simulated Annealing
   if(optimize_method=="GenSA"){
-    stopifnot("package:GenSA" %in% search()  ||  require("GenSA",quietly = TRUE) )
+    stopifnot("package:GenSA" %in% search()  ||  requireNamespace("GenSA",quietly = TRUE) )
     if(hasArg(maxit)) maxit=match.call(expand.dots=TRUE)$maxit else maxit=N*50
     controlGenSA <- list(maxit = 5000, threshold.stop = NULL, temp = 5230, 
                           visiting.param = 2.62, acceptance.param = -5, max.time = NULL, 
@@ -430,7 +430,7 @@
     upper <- constraints$max
     lower <- constraints$min
     
-    minw = try(GenSA( par = rep(1/N, N), lower = lower[1:N] , upper = upper[1:N], control = controlGenSA, 
+    minw = try(GenSA::GenSA( par = rep(1/N, N), lower = lower[1:N] , upper = upper[1:N], control = controlGenSA, 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/returnanalytics -r 3632


More information about the Returnanalytics-commits mailing list