[Returnanalytics-commits] r2047 - in pkg/PortfolioAnalytics: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 22 04:13:02 CEST 2012


Author: hezkyvaron
Date: 2012-06-22 04:13:02 +0200 (Fri, 22 Jun 2012)
New Revision: 2047

Modified:
   pkg/PortfolioAnalytics/DESCRIPTION
   pkg/PortfolioAnalytics/R/constraints.R
   pkg/PortfolioAnalytics/R/optimize.portfolio.R
Log:
- updated DESCRITION file to include ROI, quadprog, and Rglpk.
- updated ROI constraint object and solver in optimize.porfolio.

Modified: pkg/PortfolioAnalytics/DESCRIPTION
===================================================================
--- pkg/PortfolioAnalytics/DESCRIPTION	2012-06-21 16:38:02 UTC (rev 2046)
+++ pkg/PortfolioAnalytics/DESCRIPTION	2012-06-22 02:13:02 UTC (rev 2047)
@@ -3,7 +3,7 @@
 Title: Portfolio Analysis, including Numeric Methods for Optimization
     of Portfolios
 Version: 0.7.2
-Date: 2012-05-19
+Date: 2012-06-21
 Author: Kris Boudt, Peter Carl, Brian G. Peterson
 Maintainer: Brian G. Peterson <brian at braverock.com>
 Description: Portfolio optimization and analysis routines and graphics.
@@ -16,6 +16,11 @@
     quantmod,
     DEoptim,
     foreach,
-    fGarch
+    fGarch,
+    Rglpk,
+    quadprog,
+    ROI,
+    ROI.plugin.glpk,
+    ROI.plugin.quadprog
 License: GPL
 Copyright: (c) 2004-2012

Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R	2012-06-21 16:38:02 UTC (rev 2046)
+++ pkg/PortfolioAnalytics/R/constraints.R	2012-06-22 02:13:02 UTC (rev 2047)
@@ -218,20 +218,14 @@
 #' @param weight_seq seed sequence of weights, see \code{\link{generatesequence}}
 #' @author Hezky Varon
 #' @export
-constraint_ROI <- function(assets, op.problem, solver=c("glpk", "quadprog"),
-                           weight_seq=NULL)
+constraint_ROI <- function(assets, op.problem, solver=c("glpk", "quadprog"), weight_seq=NULL) 
 {
   if(problem == NULL) stop("Need to pass in optimiztion problem.")
-  solver <- solver[1]
-  require(solver, character.only=TRUE)
-  require(ROI, character.only=TRUE)
-  require(paste("ROI.plugin.", solver.method, sep=""), character.only=TRUE)
-  ## now structure and return
   return(structure(
     list(
       assets = assets,
-      op.problem = op.problem,
-      solver = solver,
+      constrainted_objective = op.problem,
+      solver = solver[1],
       weight_seq = weight_seq,
       objectives = list(),
       call = match.call()

Modified: pkg/PortfolioAnalytics/R/optimize.portfolio.R
===================================================================
--- pkg/PortfolioAnalytics/R/optimize.portfolio.R	2012-06-21 16:38:02 UTC (rev 2046)
+++ pkg/PortfolioAnalytics/R/optimize.portfolio.R	2012-06-22 02:13:02 UTC (rev 2047)
@@ -236,11 +236,12 @@
     # This will take a new constraint object that is of the same structure of a 
     # ROI constraint object, but with an additional solver arg.
     # then we can do something like this
-    weights <- ROI_solve(x=constraints$constraint, constraints$solver)$solution
+    roi.result <- ROI_solve(x=constraints$constrainted_objective, constraints$solver)
+    weights <- roi.result$solution
     names(weights) <- colnames(R)
-    out$weights<-weights
+    out$weights <- weights
     out$objective_measures <- roi.result$objval
-    out$call<-call
+    out$call <- call
   } ## end case for ROI
   
     end_t<-Sys.time()



More information about the Returnanalytics-commits mailing list