I am using the R "lpSolve" package downloaded from Cran link and it seems to give strange answers. I wanted to make sure that it is not me messing up things (which is likely the case).
For example, the problem I am trying to solve is
maximize -3x-2y
s.t 5x -y <= 1
-2x-2y <= -1
-3x-2y <= 0
The settings I have in R:
> obj
-3 -2
> cond
5 -1
-2 -2
-3 -2
> dir
"<=" "<=" "<="
> rhs
1 -1 0
With these applied to the lp function in lp.solve
> lp(direction="max", objective.in=obj, const.mat=cond, const.dir=dir, const.rhs=rhs)$objval
This returns -1, however, I know the solution is 0 instead of -1.
I also tried set the objective to be "min" instead, and I get:
> lp(direction = "max", objective.in = obj, const.mat = cond, const.dir = dir, const.rhs = rhs)$objval
[1] -1
> lp(direction = "min", objective.in = obj, const.mat = cond, const.dir = dir, const.rhs = rhs)$objval
[1] 0
How is it possible that I get a bigger value when I try to minimize the objective? Does it have something to do with negative coefficient with x? I looked through the package manual and I didn't see any related requirements for the objective function.