Gurobipy vs Pyomo Discrepancy
回答済みSummary: Using Gurobi, Pyomo and gurobipy generate equivalent .lp files but only the Pyomo version solves. How can I trace Pyomo generating the .lp file to work out the difference?
Hi Everyone,
I was hoping I could get a bit of insight. I've been using Pyomo to develop something in work using the Gurobi solver. I'm thinking of switching to the gurobipy package as I need to optimise a MIQCP model with multiple objectives.
Before I attempted to write the multi-object model in gurobipy I attempted to replicate the model I have in Pyomo but I've been failing miserably. The model .lp produced by Pyomo looks identical to the gurobipy model but the gurobipy model fails whereas the Pyomo version works as intended.
I've looked at the two .lp files generated by both approaches and they seem similar. To help me diagnose the problem I've tried to follow the workflow of Pyomo in generating the .lp file but I'm not having much success.
Happy to share any data/information to help diagnose the problem.
Thanks, Fraser :)
-
正式なコメント
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?. -
Pyomo Output:
Read LP format model from file C:\Users\FMACMI~1\AppData\Local\Temp\tmpiyrrwkzc.pyomo.lp
Reading time = 0.02 seconds
x6359: 3765 rows, 6354 columns, 15763 nonzeros
Changed value of parameter nonConvex to 2
Prev: -1 Min: -1 Max: 2 Default: -1
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 6 physical cores, 12 logical processors, using up to 12 threads
Optimize a model with 3765 rows, 6354 columns and 15763 nonzeros
Model fingerprint: 0xb2721db2
Model has 3173 quadratic objective terms
Coefficient statistics:
Matrix range [1e-04, 2e+04]
Objective range [0e+00, 0e+00]
QObjective range [2e-01, 3e+04]
Bounds range [1e+00, 1e+00]
RHS range [2e-02, 7e+03]
Presolve removed 363 rows and 384 columns
Continuous model is non-convex -- solving as a MIP.
Presolve removed 363 rows and 384 columns
Presolve time: 0.01s
Presolved: 9039 rows, 8789 columns, 29735 nonzeros
Presolved model has 2818 bilinear constraint(s)
Variable types: 8789 continuous, 0 integer (0 binary)
Root relaxation: objective 1.026381e+08, 4902 iterations, 0.09 seconds
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 1.0264e+08 0 6 - 1.0264e+08 - - 0s
H 0 0 1.026380e+08 1.0264e+08 0.00% - 0s
Explored 1 nodes (4902 simplex iterations) in 0.15 seconds
Thread count was 12 (of 12 available processors)
Solution count 1: 1.02638e+08
Optimal solution found (tolerance 1.00e-04)
Best objective 1.026380496757e+08, best bound 1.026380534995e+08, gap 0.0000%1 -
Gurobipy Output:
Changed value of parameter nonConvex to 2
Prev: -1 Min: -1 Max: 2 Default: -1
Changed value of parameter QCPDual to 1
Prev: 0 Min: 0 Max: 1 Default: 0
Changed value of parameter TimeLimit to 480.0
Prev: inf Min: 0.0 Max: inf Default: inf
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 6 physical cores, 12 logical processors, using up to 12 threads
Optimize a model with 3764 rows, 6353 columns and 15763 nonzeros
Model fingerprint: 0x70d8dc90
Model has 3173 quadratic objective terms
Coefficient statistics:
Matrix range [1e-04, 2e+04]
Objective range [0e+00, 0e+00]
QObjective range [2e-01, 3e+04]
Bounds range [1e+00, 1e+00]
RHS range [2e-02, 7e+03]
Presolve time: 0.00s
Barrier solved model in 0 iterations and 0.00 seconds
Model is infeasible or unbounded1 -
Hey guys, figured out my fairly basic error. Pyomo defaults variables with no lower bound to inf whereas gurobipy defaults to lb=0.
Stupid mistake easily overlooked, hope this helps someone in the future.
1
投稿コメントは受け付けていません。
コメント
4件のコメント