I have a linear programming problem that I'm trying to solve in R
. I have used lpSolve
package. lpSolve by default uses primal simplex algorithm to obtain solution. What if I want to change the algorithm to dual simplex ? The results vary widely between the two algorithms. Are there any other packages that would help to solve the problem below using dual simplex algorithm.
library("lpSolve")
f.obj <- c(rep(1,12),rep(0,4))
f.cons <- matrix(c(1,-1,0,0,0,0,0,0,0,0,0,0,1,-1,0,0,
0,0,1,-1,0,0,0,0,0,0,0,0,1,0,-1,0,
0,0,0,0,1,-1,0,0,0,0,0,0,1,0,0,-1,
0,0,0,0,0,0,1,-1,0,0,0,0,0,1,-1,0,
0,0,0,0,0,0,0,0,1,-1,0,0,0,1,0,-1,
0,0,0,0,0,0,0,0,0,0,1,-1,0,0,1,-1),nrow=6,byrow=T)
f.dir <- rep("=",6)
f.rhs <- c(-1.0986,1.6094,-1.0986,1.94591,1.3863,-1.7917)
g <- lp ("min", f.obj, f.cons, f.dir, f.rhs,compute.sens=TRUE)
g$solution
Primal Simplex using lpSolve in R
is as follows:
0 0 0 0 0 0.91630 0.0 0.76209 0.47 0 0 0 1.60940 2.70800 0 1.79170
Dual Simplex using Lingo software and SAS is as follows:
0 0.76214 0 0 1.23214 0 0 0 0.15415 0 0 0 0.8473 1.9459 0 1.7918
The objective function is same for both the algorithms is 2.14839