对R LP投资任何体重

问题描述

我想找到这10只股票的最佳权重,但他总是只投资那些收益最高的股票。我希望每个份额都包括在内。预先感谢您的帮助。

# Load LP
require(lpSolve)

#没有卖空!!!! #100%投资

# Coefficient vector of the objective function
C = c(-4.77,-0.87,-7.99,0.9,-4.71,-4.04,-11.22,7.56,5.75,-4.64)


#Matrix with restrictions
A = matrix (c(1,-4.77,1,-4.64),nrow=2)

# Vector with maximum values ​​for the restriction
B = cbind(1,-2.4)

# Specifying the restriction sign
ConstraintDirection = c("=",">=")

# Solution
Solution = lp(direction="max",objective.in = C,const.mat = A,const.dir = ConstraintDirection,const.rhs = B,int.vec = 1:20,compute.sens=TRUE)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)