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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 26 20:49:30 CEST 2013


Author: rossbennett34
Date: 2013-08-26 20:49:30 +0200 (Mon, 26 Aug 2013)
New Revision: 2897

Modified:
   pkg/PortfolioAnalytics/R/generics.R
   pkg/PortfolioAnalytics/R/optFUN.R
Log:
fixing error with group constraints in optFUN and summary method

Modified: pkg/PortfolioAnalytics/R/generics.R
===================================================================
--- pkg/PortfolioAnalytics/R/generics.R	2013-08-26 18:48:50 UTC (rev 2896)
+++ pkg/PortfolioAnalytics/R/generics.R	2013-08-26 18:49:30 UTC (rev 2897)
@@ -554,7 +554,7 @@
     n.groups <- length(groups)
     group_weights <- rep(0, n.groups)
     for(i in 1:n.groups){
-      group_weights[i] <- sum(weights[groups[[i]]])
+      group_weights[i] <- sum(object$weights[groups[[i]]])
     }
     names(group_weights) <- group_labels
     print(group_weights)

Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R	2013-08-26 18:48:50 UTC (rev 2896)
+++ pkg/PortfolioAnalytics/R/optFUN.R	2013-08-26 18:49:30 UTC (rev 2897)
@@ -30,7 +30,7 @@
     n.groups <- length(constraints$groups)
     Amat.group <- matrix(0, nrow=n.groups, ncol=N)
     for(i in 1:n.groups){
-      Amat.group[i, groups[[i]]] <- 1
+      Amat.group[i, constraints$groups[[i]]] <- 1
     }
     if(is.null(constraints$cLO)) cLO <- rep(-Inf, n.groups)
     if(is.null(constraints$cUP)) cUP <- rep(Inf, n.groups)
@@ -90,7 +90,7 @@
     n.groups <- length(constraints$groups)
     Amat.group <- matrix(0, nrow=n.groups, ncol=N)
     for(i in 1:n.groups){
-      Amat.group[i, groups[[i]]] <- 1
+      Amat.group[i, constraints$groups[[i]]] <- 1
     }
     if(is.null(constraints$cLO)) cLO <- rep(-Inf, n.groups)
     if(is.null(constraints$cUP)) cUP <- rep(Inf, n.groups)
@@ -175,7 +175,7 @@
     n.groups <- length(constraints$groups)
     Amat.group <- matrix(0, nrow=n.groups, ncol=N)
     for(i in 1:n.groups){
-      Amat.group[i, groups[[i]]] <- 1
+      Amat.group[i, constraints$groups[[i]]] <- 1
     }
     if(is.null(constraints$cLO)) cLO <- rep(-Inf, n.groups)
     if(is.null(constraints$cUP)) cUP <- rep(Inf, n.groups)
@@ -243,7 +243,7 @@
     n.groups <- length(constraints$groups)
     Amat.group <- matrix(0, nrow=n.groups, ncol=N)
     for(i in 1:n.groups){
-      Amat.group[i, groups[[i]]] <- 1
+      Amat.group[i, constraints$groups[[i]]] <- 1
     }
     if(is.null(constraints$cLO)) cLO <- rep(-Inf, n.groups)
     if(is.null(constraints$cUP)) cUP <- rep(Inf, n.groups)
@@ -343,7 +343,7 @@
     n.groups <- length(constraints$groups)
     Amat.group <- matrix(0, nrow=n.groups, ncol=m)
     for(i in 1:n.groups){
-      Amat.group[i, groups[[i]]] <- 1
+      Amat.group[i, constraints$groups[[i]]] <- 1
     }
     if(is.null(constraints$cLO)) cLO <- rep(-Inf, n.groups)
     if(is.null(constraints$cUP)) cUP <- rep(Inf, n.groups)



More information about the Returnanalytics-commits mailing list