Open ryanjoneil opened 1 year ago
Noting that this is an issue with Cbc. I posed the question on #164 as to whether it makes sense to defer writing model files using it, since it seems to have issues generating correct output.
Confirmed: If I change m = Model(sense=MAXIMIZE)
to m = Model(sense=MINIMIZE)
and switch the sign of every variable in the objective function in my Python code, the the result of m.write('model.mps')
is equivalent to m.write('model.lp')
before the changes.
Maybe related to https://github.com/coin-or/Cbc/issues/519
Describe the bug
When I formulate a model in python-mip to maximize an objective function and write it to a
.mps
file, the objective coefficients have the wrong sign.To Reproduce
Construct the 0-1 knapsack model from the examples and write it to a
.mps
file.Now call
cbc
orhighs
on the resulting file.The optimal objective is (incorrectly) 0.
Expected behavior
This happens because the MPS file is minimizing the objective. The coefficients of the output file should be
-
in this case.If I change their signs:
Then the solution is correct.
Desktop (please complete the following information):