Wrong result after explicitly invoking presolve in Python
回答済みHi there,
I just found gurobi produced a wrong result after explicitly invoking presolve in Python. Not sure if it is a bug. The following is a very simple Python code that reads a model from a .lp file and solve it. This model contains lots of redundant variables and constraints. So I would like to see how presolve can reduce them.
model = gp.read('./model.lp')
model.optimize()
if model.status == GRB.OPTIMAL:
print('Without explicitly invoking presolve: ' + str(model.objVal))
p = model.presolve()
p.optimize()
if p.status == GRB.OPTIMAL:
print('After explicitly invoking presolve: ' + str(p.objVal))
The result is:
Using license file /home/chaohuang/gurobi.lic
Academic license - for non-commercial use only
Read LP format model from file ./model.lp
Reading time = 0.91 seconds
: 60784 rows, 81568 columns, 401568 nonzeros
Gurobi Optimizer version 9.0.0 build v9.0.0rc2 (linux64)
Optimize a model with 60784 rows, 81568 columns and 401568 nonzeros
Model fingerprint: 0xbb4d9678
Model has 65286 general constraints
Variable types: 61568 continuous, 20000 integer (20000 binary)
Coefficient statistics:
Matrix range [1e-04, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [7e-06, 2e+00]
RHS range [1e-03, 1e+00]
Presolve removed 60784 rows and 81568 columns
Presolve time: 0.47s
Presolve: All rows and columns removed
Explored 0 nodes (0 simplex iterations) in 0.49 seconds
Thread count was 1 (of 12 available processors)
Solution count 1: 0.193681
Optimal solution found (tolerance 1.00e-04)
Best objective 1.936813120069e-01, best bound 1.936813120069e-01, gap 0.0000%
Without explicitly invoking presolve: 0.1936813120069167
Presolve removed 60784 rows and 81568 columns
Presolve time: 0.41s
Gurobi Optimizer version 9.0.0 build v9.0.0rc2 (linux64)
Optimize a model with 0 rows, 0 columns and 0 nonzeros
Model fingerprint: 0xf9715da1
Coefficient statistics:
Matrix range [0e+00, 0e+00]
Objective range [0e+00, 0e+00]
Bounds range [0e+00, 0e+00]
RHS range [0e+00, 0e+00]
Presolve time: 0.00s
Presolve: All rows and columns removed
Iteration Objective Primal Inf. Dual Inf. Time
0 0.0000000e+00 0.000000e+00 0.000000e+00 0s
Solved in 0 iterations and 0.00 seconds
Optimal objective 0.000000000e+00
After explicitly invoking presolve: 0.0
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
To solve a model, Gurobi applies presolve, then solves the presolved model and finally translates the solution from to presolved model back to the original one. However, when you use the presolve() method yourself, the resulting model will not contain the information about the original model or the necessary translation.
As you can also see in the log for the first solve, presolve is able to remove all rows and columns. Hence the objective value will be 0.
Please note that it is not recommend to call the presolve() method yourself.
0
投稿コメントは受け付けていません。
コメント
2件のコメント