Adding a constant to the objective function can lead to a bug
回答済みThe following LP has a solution but Gurobi gives Unbounded. I think this might be a bug, because erasing “-94” solving and then subtracting it myself at the end I have the same solution. Why Gurobi does not accept this negative constant in this minimization problem?
Minimize
obj1: 15 x1 + 15 x2 + 13 x3 + 73 x4 + 73 x5 + 67 x6 - 94
Subject To
c1: 2 x1 + 6 x4 >= 7
c2: 2 x1 + 2 x2 + 2 x3 + 6 x4 + 6 x5 + 6 x6 >= 87
c3: x7 + x8 = 1
c4: x1 - 4 x7 <= 0
c5: x2 - 20 x7 <= 0
c6: x4 - 2 x8 <= 0
c7: x5 - 14 x8 <= 0
c8: x3 - 20 x7 <= 0
c9: x6 - 14 x8 <= 0
c10: x1 + x2 <= 20
c11: x4 + x5 <= 100
c12: x3 + x9 <= 20
c13: x6 + x10 <= 100
c14: x1 + x2 - 20 x7 <= 0
c15: x4 + x5 - 15 x8 <= 0
c16: x3 - 20 x7 <= 0
c17: x6 - 14 x8 <= 0
Bounds
0 <= x7 <= 1
0 <= x8 <= 1
End
-
Did you manually add the
- 94to the objective function? Gurobi's LP reader interprets this as a variable named94with objective coefficient-1. This should instead be written as- 94 Constantwith another constraint in theBoundssection fixingConstantto 1. However, we don't recommend manually editing model files, as it is prone to error.0 -
It's also strange to see
0 <= x7 <= 1
0 <= x8 <= 1since Gurobi does not write lower bounds of 0 to file. If a lower bound for a variable is not stated in the file then that variable has a lower bound of 0 - i.e. all your variables in this model have lower bounds of 0 (just in case this is not what you wanted).
- Riley
0 -
Ok, I understand now. Thanks.
The thing is that I am comparing different solvers for one problem. The .lp was written out by one of them, and I am giving this .lp to the others. It turns out they do not read it all in the same way then.
Thank you,
Rui0
サインインしてコメントを残してください。
コメント
3件のコメント