我在斗智斗勇,请帮忙!下面是问题的设置。顺便说一句,为什么当有超过8个变量时我无法查看模型细节?
我已经设置了约束来将答案限制在窗口内。为变量10提供的解决方案不在约束范围内。有什么我想念的吗?
[25,] "0" "0" "0" "0" "0" "0" "1" "0" "0" "0" "<=" "0.0096"
[26,] "0" "0" "0" "0" "0" "0" "1" "0" "0" "0" ">" "-0.0096"
[27,] "0" "0" "0" "0" "0" "0" "1" "0" "0" "0" "<=" "0.00096"
[28,] "0" "0" "0" "0" "0" "0" "1" "0" "0" "0" ">" "-0.00096"
[29,] "0" "0" "0" "0" "0" "0" "0" "1" "0" "0" "<=" "0.029"
[30,] "0" "0" "0" "0" "0" "0" "0" "1" "0" "0" ">" "-0.029"
[31,] "0" "0" "0" "0" "0" "0" "0" "1" "0" "0" "<=" "0.0029"
[32,] "0" "0" "0" "0" "0" "0" "0" "1" "0" "0" ">" "-0.0029"
[33,] "0" "0" "0" "0" "0" "0" "0" "0" "1" "0" "<=" "0.014"
[34,] "0" "0" "0" "0" "0" "0" "0" "0" "1" "0" ">" "-0.014"
[35,] "0" "0" "0" "0" "0" "0" "0" "0" "1" "0" "<=" "0.0014"
[36,] "0" "0" "0" "0" "0" "0" "0" "0" "1" "0" ">" "-0.0014"
[37,] "0" "0" "0" "0" "0" "0" "0" "0" "0" "1" "<=" "0.0028"
[38,] "0" "0" "0" "0" "0" "0" "0" "0" "0" "1" ">" "-0.0028"
[39,] "0" "0" "0" "0" "0" "0" "0" "0" "0" "1" "<=" "0.00028"
[40,] "0" "0" "0" "0" "0" "0" "0" "0" "0" "1" ">" "-0.00028"
[41,] "1" "1" "1" "1" "1" "1" "1" "1" "1" "1" "=" "0"
Browse[2]> n
debug at #60: cat(get.objective(lpIr), "\n")
Browse[2]> get.variables(lpIr)
[1] 0.00284 0.00024 0.00038 0.00112 0.00210 0.00778 0.00096 0.00290 0.00140 -0.01972
tRatio <- (tDelta+IR*factor)
set.objfn(lpIr,tRatio)
lp.control(lpIr,sense='max')
罗兰,
我添加了源代码。初始帖子不包括因为我认为浏览器输出显示设置。提前感谢您的帮助。
set.bounds(LPIR,低级=代表(-100,10)) ##设定目标方向,最大化信息比
constMat <- matrix(0.0,nrow=41,ncol=length(delta))
rightV <-rep(NA,41)
constV <-rep(NA,41)
for (i in 1:10)
{
inx = ((i-1)*4)
constMat[inx+1,i] <- 1
rightV[inx+1] <- (pWeight[i]*.2)-actWeight[i]
constV[inx+1] <- "<="
constMat[inx+2,i] <- 1
tmp1 = (pWeight[i]*-.2)-actWeight[i]
rightV[inx+2] <- tmp1
constV[inx+2] <- ">"
constMat[inx+3,i] <- 1
tmp1 = (pWeight[i]*.02)
rightV[inx+3] <- tmp1
constV[inx+3] <- "<="
constMat[inx+4,i] <- 1
tmp1 = (pWeight[i]*-.02)
rightV[inx+4] <- tmp1
constV[inx+4] <- ">"
}
constMat[41,]<-rep(1,10)
rightV[41] <- 0
constV[41] <- "="
for (i in 1:10)
{
set.column(lpIr,i,constMat[,i])
}
tDelta<- delta
tRatio <- (tDelta+IR*factor)
set.objfn(lpIr,tRatio)
## cat(rightV,&#34; \ n&#34;)
set.rhs(lpIr,rightV)
set.constr.type(lpIr,constV)
solve(lpIr,-l)
cat(get.objective(lpIr),"\n")
##cat(tRatio,"\n")
cat(get.variables(lpIr),"\n")
res = get.variables(lpIr)