[Returnanalytics-commits] r3356 - pkg/PortfolioAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Apr 8 21:23:40 CEST 2014
Author: rossbennett34
Date: 2014-04-08 21:23:40 +0200 (Tue, 08 Apr 2014)
New Revision: 3356
Modified:
pkg/PortfolioAnalytics/R/optFUN.R
Log:
workaround for ROI with gmv_opt to respect lower bounds of 0
Modified: pkg/PortfolioAnalytics/R/optFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/optFUN.R 2014-04-08 19:22:04 UTC (rev 3355)
+++ pkg/PortfolioAnalytics/R/optFUN.R 2014-04-08 19:23:40 UTC (rev 3356)
@@ -47,14 +47,14 @@
rhs.vec <- c(rhs.vec, constraints$min_sum, -constraints$max_sum)
# Add min box constraints
- # Amat <- rbind(Amat, diag(N))
- # dir.vec <- c(dir.vec, rep(">=", N))
- # rhs.vec <- c(rhs.vec, constraints$min)
+ Amat <- rbind(Amat, diag(N))
+ dir.vec <- c(dir.vec, rep(">=", N))
+ rhs.vec <- c(rhs.vec, constraints$min)
# Add max box constraints
- # Amat <- rbind(Amat, -1*diag(N))
- # dir.vec <- c(dir.vec, rep(">=", N))
- # rhs.vec <- c(rhs.vec, -constraints$max)
+ Amat <- rbind(Amat, -1*diag(N))
+ dir.vec <- c(dir.vec, rep(">=", N))
+ rhs.vec <- c(rhs.vec, -constraints$max)
# Applying box constraints
lb <- constraints$min
@@ -92,10 +92,10 @@
# rhs.vec[is.infinite(rhs.vec) & (rhs.vec <= 0)] <- -.Machine$double.xmax
# rhs.vec[is.infinite(rhs.vec) & (rhs.vec >= 0)] <- .Machine$double.xmax
- # Remove the rows of Amat and elements of rhs.vec where rhs.vec is Inf or -Inf
- # Amat <- Amat[!is.infinite(rhs.vec), ]
- # dir.vec <- dir.vec[!is.infinite(rhs.vec)]
- # rhs.vec <- rhs.vec[!is.infinite(rhs.vec)]
+ # Remove the rows of Amat and elements of dir.vec and rhs.vec where rhs.vec is Inf or -Inf
+ Amat <- Amat[!is.infinite(rhs.vec), ]
+ dir.vec <- dir.vec[!is.infinite(rhs.vec)]
+ rhs.vec <- rhs.vec[!is.infinite(rhs.vec)]
# Set up the quadratic objective
if(!is.null(lambda_hhi)){
More information about the Returnanalytics-commits
mailing list