Last active
September 29, 2016 22:38
-
-
Save odow/61a1cb2824a670b4e635843b004f1dcc to your computer and use it in GitHub Desktop.
Bug in Gurobi v6.5.2 and earlier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Minimize | |
| - C2 | |
| Subject To | |
| R0: C0 + C1 >= 0 | |
| R1: 2 C0 - C1 >= 0 | |
| R2: C2 >= -2 | |
| R3: C0 - C2 >= 0 | |
| R4: - 1.000001 C0 + C1 - C2 >= 0 | |
| Bounds | |
| C0 <= 1 | |
| -infinity <= C2 <= 1 | |
| End |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Minimize | |
| - C2 | |
| Subject To | |
| R0: C0 + C1 >= 0 | |
| R1: 2 C0 - C1 >= 0 | |
| R2: - C2 >= -2 | |
| R3: C0 + C2 >= 0 | |
| R4: - 1.000001 C0 + C1 + C2 >= 0 | |
| Bounds | |
| C0 <= 1 | |
| C2 >= -1 | |
| End |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gurobipy import * | |
| m = Model("Gurobi Bug") | |
| m.modelSense = GRB.MINIMIZE | |
| x = m.addVar(lb=0, ub=1) | |
| y = m.addVar(lb=0, ub=GRB.INFINITY) | |
| z = m.addVar(lb=-GRB.INFINITY, ub=1, obj=-1) | |
| m.update() | |
| m.addConstr( x + y >= 0) | |
| m.addConstr(2*x - y >= 0) | |
| m.addConstr( z >= -2) | |
| m.addConstr( x - z >= 0) | |
| m.update() | |
| m.optimize() | |
| print "The solution vector is:", m.getAttr("x",m.getVars()) | |
| m.addConstr(-1.000001*x + y - z >= 0) | |
| m.update() | |
| m.write("correct_model.lp") | |
| m.optimize() | |
| m.write("reformulated_model.lp") | |
| print "The solution vector is:", m.getAttr("x",m.getVars()) | |
| c = m.getAttr("Obj", m.getVars()) | |
| m.setAttr("Obj", m.getVars(), c) | |
| m.update() | |
| m.write("incorrect_model.lp") | |
| m.optimize() | |
| print "The solution vector is:", m.getAttr("x",m.getVars()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Minimize | |
| C2 | |
| Subject To | |
| R0: C0 + C1 >= 0 | |
| R1: 2 C0 - C1 >= 0 | |
| R2: - C2 >= -2 | |
| R3: C0 + C2 >= 0 | |
| R4: - 1.000001 C0 + C1 + C2 >= 0 | |
| Bounds | |
| C0 <= 1 | |
| C2 >= -1 | |
| End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment