[R] Linear programming problem, RGPLK - "no feasible solution".
Liu Evans, Gareth
Gareth.Liu-Evans at liverpool.ac.uk
Mon Oct 10 13:53:27 CEST 2011
In my post at https://stat.ethz.ch/pipermail/r-help/2011-October/292019.html I included an undefined term "ej". The problem code should be as follows. It seems like a simple linear programming problem, but for some reason my code is not finding the solution.
obj <- c(rep(0,3),1)
col1 <-c(1,0,0,1,0,0,1,-2.330078923,0)
col2 <-c(0,1,0,0,1,0,1,-2.057855981,0)
col3 <-c(0,0,1,0,0,1,1,-1.885177032,0)
col4 <-c(-1,-1,-1,1,1,1,0,0,1)
mat <- cbind(col1, col2, col3, col4)
dir <- c(rep("<=", 3), rep(">=", 3), rep("==", 2), ">=")
rhs <- c(rep(0, 7), 1, 0)
sol <- Rglpk_solve_LP(obj, mat, dir, rhs, types = NULL, max = FALSE,
bounds = c(-100,100), verbose = TRUE)
The R output says there is no feasible solution, but e.g. (-2.3756786, 0.3297676, 2.0459110, 2.3756786) is feasible.
The output is
"GLPK Simplex Optimizer, v4.42
9 rows, 4 columns, 19 non-zeros
0: obj = 0.000000000e+000 infeas = 1.000e+000 (2)
PROBLEM HAS NO FEASIBLE SOLUTION"
One other thing, a possible bug - if I run this code with "dir" shorter than it should be, R crashes. My version of R is 2.131.56322.0, and I'm running it on Windows 7.
Regards,
Gareth
More information about the R-help
mailing list