[R] Simplex difficulties
Gerry Brush
gbrush at darwin.sfbr.org
Fri Jan 25 17:20:50 CET 2002
I'm exploring the simplex algorithm with a simple transportation problem
of the form:
minimize:
8a + 6b + 10c + 9d + 5e + 7f
subject to the constraints:
a + b + c = 11
d + e + f = 14
a + d = 10
b + e = 8
c + f = 7
I've implemented this in R (1.4.0 (2001-12-19), SunOS 5.7) as:
require(boot)
costs = c(8,6,10,9,5,7)
constraints = c(
1,1,1,0,0,0,
0,0,0,1,1,1,
1,0,0,1,0,0,
0,1,0,0,1,0,
0,0,1,0,0,1
)
consmat = matrix(constraints, nrow=5, ncol=6, byrow=T)
consrhs = c(11,14,10,8,7)
simpres = simplex(a=costs, A3=consmat, b3=consrhs, maxi=F)
where I get the error from the simplex function:
Error in simplex1(out1$a[1:(n + m1 + m2)], out1$A[, 1:(n + m1 +
m2)], :
subscript out of bounds
According to Gass (An Illustrated Guide to Linear Programming) the
solution should be a=10, b=1, c=0, d=0, e=7, f=7 to minimize the
objective function at 170. Have I misunderstood the use of the simplex
function here?
Thanks,
Gerry Brush
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list