我希望为我的参数子集设置一个公共约束:
c2 <- 2
nFeatures = 6
W2 <- rep(1,nFeatures)
w2 <- W2/sum(W2)
fguess2 <- 0.3
startParms2 <- c(c2,fguess2,w2)
names(startParms2) <- c("c2", "fguess",
"w21","w22","w23","w24","w25","w26")
xout2 <- optim(par=startParms2, fn=rmsd,
data1=mydata2, method = "L-BFGS-B",
lower = rep(0,8),
upper = c(Inf,1,1,1,1,1,1,1))
print(xout2)
当前,属于向量w2
的所有6个参数均被限制为单个最大值1。
我想做的就是将这6个参数的总和限制为1(而其余2个参数则保持当前约束)。