[Returnanalytics-commits] r2779 - pkg/PortfolioAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 14 02:52:53 CEST 2013
Author: rossbennett34
Date: 2013-08-14 02:52:52 +0200 (Wed, 14 Aug 2013)
New Revision: 2779
Modified:
pkg/PortfolioAnalytics/R/optFUN.R
Log:
adding exposure constraint to maxret_milp_opt
Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R 2013-08-14 00:33:11 UTC (rev 2778)
+++ pkg/PortfolioAnalytics/R/optFUN.R 2013-08-14 00:52:52 UTC (rev 2779)
@@ -192,6 +192,15 @@
rhs <- c(rhs, constraints$cLO, -constraints$cUP)
}
+ # Add the factor exposures to Amat, dir, and rhs
+ if(!is.null(constraints$B)){
+ t.B <- t(B)
+ zeros <- matrix(data=0, nrow=nrow(t.B), ncol=ncol(t.B))
+ Amat <- rbind(Amat, cbind(t.B, zeros), cbind(-t.B, zeros))
+ dir <- c(dir, rep(">=", 2 * nrow(t.B)))
+ rhs <- c(rhs, constraints$lower, -constraints$upper)
+ }
+
objL <- c(-moments$mean, rep(0, N))
# Only seems to work if I do not specify bounds
More information about the Returnanalytics-commits
mailing list