[R] Solve linear program without objective function

Andreas Wittmann andreas_wittmann at gmx.de
Fri Dec 4 09:27:36 CET 2009


Dear R-users,

i try to solve to following linear programm in R

0 * x_1 + 2/3 * x_2 + 1/3 * x_3 + 1/3 * x_4 = 0.3
x_1 + x_2 + x_3 + x_4 = 1
x_1, x_2, x_3, x_4 > 0,
x_1, x_2, x_3, x_4 < 1

as you can see i have no objective function here besides that i use the 
following code.


library(lpSolve)

f.obj<-c(1,1,1,1)
f.con<-matrix(c(0,2/3,1/3,1/3,
                1,1,1,1,
                1,0,0,0,
                0,1,0,0,
                0,0,1,0,
                0,0,0,1),nrow=6,byrow=TRUE)
f.dir <- c("=", "=", ">", ">", ">", ">")
f.rhs <- c(0.3, 1, 0, 0, 0, 0)

lp ("max", f.obj, f.con, f.dir, f.rhs)$solution


the problem is, the condition x_1, x_2, x_3, x_4 > 0 is not fulfilled.

Any advice would be very helpful.

best regards

Andreas




More information about the R-help mailing list