[R] Simplex(boot) returning invalid answer

Andrew Stoneman stoneman at otsys.com
Fri Mar 11 18:09:15 CET 2005


In trying to use simplex() from the boot package, I have run into a 
situation that doesn't seem like it should be possible.  It is claiming 
that it has solved the LP, but returns a vector of all zeros, which 
does not satisfy the constraints I passed in.  A small example:

 > ubMatrix <- matrix(c(1,1,-1,0,-1,-1), 3, 2)
 > ubVector <- c(2,1,-1)
 > objective <- c(0,1)

 > ubMatrix
      [,1] [,2]
[1,]    1    0
[2,]    1   -1
[3,]   -1   -1
 > ubVector
[1]  2  1 -1

 > smplx <- simplex( a = objective, A1 = ubMatrix, b1 = ubVector)

 > smplx$solved
[1] 1
 > smplx$soln
x1 x2
  0  0

 > ubMatrix %*% smplx$soln <= ubVector
       [,1]
[1,]  TRUE
[2,]  TRUE
[3,] FALSE

The correct answer to the problem, which also has a value of 0, but 
satisfies the constraints is [1, 0] :

 > ubMatrix %*% c(1,0) <= ubVector
      [,1]
[1,] TRUE
[2,] TRUE
[3,] TRUE

Any ideas what's going on here?  Am I missing something obvious?  Any 
advice on how I might work around this problem would be greatly 
appreciated.

Andrew




More information about the R-help mailing list