I'm trying to solve the following optimization problem with R lpSolve package:
1.007825*x1 +12.000000*x2 +15.99492*x3 +14.00307*x4 +31.97207*x5 +30.97376*x6 >= 10
1.007825*x1 +12.000000*x2 +15.99492*x3 +14.00307*x4 +31.97207*x5 +30.97376*x6 <= 15
1*x1 - 2*x2 + 0*x3 -1*x4 +0*x5 -3*x6 <= 2
xi >= 0, where i = [1,2,3,4,5,6]
My objective function is:
1.007825*x1 +12.000000*x2 +15.99492*x3 +14.00307*x4 +31.97207*x5 +30.97376*x6
I create the matrix of constraints in the standard form (A):
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] -1.007825 -12 -15.99492 -14.00307 -31.97207 -30.97376
[2,] 1.007825 12 15.99492 14.00307 31.97207 30.97376
[3,] 1.000000 -2 0.00000 -1.00000 0.00000 -3.00000
[4,] -1.000000 0 0.00000 0.00000 0.00000 0.00000
[5,] 0.000000 -1 0.00000 0.00000 0.00000 0.00000
[6,] 0.000000 0 -1.00000 0.00000 0.00000 0.00000
[7,] 0.000000 0 0.00000 -1.00000 0.00000 0.00000
[8,] 0.000000 0 0.00000 0.00000 -1.00000 0.00000
[9,] 0.000000 0 0.00000 0.00000 0.00000 -1.00000
I create the matrix of borders (b):
[,1]
[1,] -10
[2,] 15
[3,] 2
[4,] 0
[5,] 0
[6,] 0
[7,] 0
[8,] 0
[9,] 0
and the objective function (f):
f = c(1.007825, 12.000000, 15.99492, 14.00307, 31.97207, 30.97376)
When I put it into the code:
out = lp("min",f,A,rep("<=",9),b,all.int=TRUE),
I get the solution c(0,0,0,1,0,0), although I know that the solution is c(0,1,0,0,0,0). If I change the right border (instead of 15 I make 13), everything works. What could be the problem?