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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 19 01:45:38 CEST 2013


Author: rossbennett34
Date: 2013-06-19 01:45:38 +0200 (Wed, 19 Jun 2013)
New Revision: 2361

Modified:
   pkg/PortfolioAnalytics/R/constraints.R
Log:
modified group_constraint to use the constraint_v2 constructor and return a constraint object

Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R	2013-06-18 23:32:20 UTC (rev 2360)
+++ pkg/PortfolioAnalytics/R/constraints.R	2013-06-18 23:45:38 UTC (rev 2361)
@@ -388,15 +388,18 @@
 #' constructor for group_constraint
 #' 
 #' This function is called by add.constraint when type="group" is specified. see \code{\link{add.constraint}}
-#'  
+#'
+#' @param type character type of the constraint
 #' @param assets number of assets, or optionally a named vector of assets specifying seed weights
 #' @param groups vector specifying the groups of the assets
 #' @param group_min numeric or vector specifying minimum weight group constraints
 #' @param group_max numeric or vector specifying minimum weight group constraints
+#' @param enabled TRUE/FALSE
+#' @param \dots any other passthru parameters to specify box and/or group constraints
 #' @author Ross Bennett
 #' @seealso \code{\link{add.constraint}}
 #' @export
-group_constraint <- function(assets, groups, group_min, group_max) {
+group_constraint <- function(type, assets, groups, group_min, group_max, enabled=FALSE, ...) {
   nassets <- length(assets)
   ngroups <- length(groups)
   
@@ -418,7 +421,11 @@
   }
   if (length(group_max) != ngroups) stop(paste("length of group_max must be equal to 1 or the length of groups:", ngroups))
   
-  return(list(groups=groups, cLO=group_min, cUP=group_max))
+  Constraint <- constraint_v2(type, ...)
+  Constraint$groups <- groups
+  Constraint$cLO <- group_min
+  Constraint$cUP <- group_max
+  return(Constraint)
 }
 
 



More information about the Returnanalytics-commits mailing list