0

我无能为力,请帮助!以下是问题的设置。顺便问一下,当变量超过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,lower=rep(-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,"\n")

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)
4

0 回答 0