s********n 发帖数: 5 | 1 有一个线性规划问题,想用Simplex解决,未知数X为47维
enj是47维向量,M1和M2均为1000*48维矩阵,
运行下列语句的时候
simplex(a=enj,A1=M1[,2:48],b1=t(M1[,1]),A2=M2[,2:48],b2=t(M2[,1]),maxi=TRUE)
提示错误如下
Error in as.vector(X) %*% t(as.vector(Y)) : non-conformable arguments
取消了b1和b2的转置提示同样的错误
请问有人知道是哪里写错了么,谢谢 | t**i 发帖数: 688 | 2 enj = rnorm(3, mean=3,sd=1)
M1 = matrix(rnorm(40,mean=0,sd=1),ncol=4,byrow=TRUE)
M2 = matrix(rnorm(40,mean=0,sd=1),ncol=4,byrow=TRUE)
require(boot)
simplex(a=enj,A1=M1[,2:4],b1=t(M1[,1]),A2=M2[,2:4],b2=t(M2[,1]),maxi=TRUE)
Linear Programming Results
Call : simplex(a = enj, A1 = M1[, 2:4], b1 = t(M1[, 1]), A2 = M2[, 2:4],
b2 = t(M2[, 1]), maxi = TRUE)
Maximization Problem with Objective Function Coefficients
x1 x2 x3
2.088811 4.114023 2.513823
No feasible solution could be f | t**i 发帖数: 688 | 3 Check your data objects and make sure they are vectors and matrices,
respectively. Also check their lengths/dimensions.
Useful commands:
class()
dim()
length() | s********n 发帖数: 5 | 4 谢谢Tosi地回答,这个问题已经解决了。我原来读入的是data.frame,需要转化成
matrix.
现在遇到一个新的问题,
Error in while (!all(obfun > -eps) && (it <= n.iter)) { :
missing value where TRUE/FALSE needed
有朋友知道可能是哪里的问题么,谢谢先 | t**i 发帖数: 688 | 5 I am not familiar with simplex(), but this error seems to stem from
iteration/convergence criteria. Either obfun> -eps or it<=n.iter gives a NA
and that caused the problem. Try to play with eps or n.iter options.
However, caution is needed because the thus-generated results may not have
been drawn from the convergence status. |
|