google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.75k stars 2.08k forks source link

Gurobi default parameter values #3459

Closed torressa closed 1 year ago

torressa commented 1 year ago

What version of OR-Tools and what language are you using?

Version: main Language: C++

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)

What did you expect to see

Presolve By default, the solver should be allowed to use an automatic Presolve setting. Setting it to 1 (conservative) prevents Gurobi from automatically using an aggressive presolve and may very likely harm some models.

Threads By default, the solver should be allowed to use detect the number of Threads automatically. Setting it to 4 is potentially (very!) harmful on larger machines.

What did you see instead?

Presolve

The default value set for Gurobi Presolve parameter is 1 ((int)true) from

https://github.com/google/or-tools/blob/82750ac12f1ee5354e1c7869894d9af3508778f2/ortools/linear_solver/gurobi_interface.cc#L1087-L1088

To fix this, simply remove the two lines (do not set any value), or set it to -1 (automatic).

Threads

Similarly, for the threads, there is a hard-coded limit of 4 threads, declared

https://github.com/google/or-tools/blob/82750ac12f1ee5354e1c7869894d9af3508778f2/ortools/linear_solver/gurobi_interface.cc#L73-L74

and set: https://github.com/google/or-tools/blob/82750ac12f1ee5354e1c7869894d9af3508778f2/ortools/linear_solver/gurobi_interface.cc#L622-L623

Again, an easy fix would be removing these lines.

lperron commented 1 year ago

why not use solver specific parameters as string ?

Flags are not accessible from non c++ languages.

torressa commented 1 year ago

These parameters are set by default (from the C++ side) for all languages. So unless users specifically change these parameters they will have these values. I think this should be changed, as unless you call solver.EnableOutput() they will not be aware, and as I said, this is less than ideal.

torressa commented 1 year ago

Actually, the threads parameter is not enforced, it is only presolve.

torressa commented 3 months ago

This is still not fixed.

Running the basic_example.py with solver.EnableOutput() and Gurobi as the solver shows:

Set parameter FeasibilityTol to value 1e-07
Set parameter IntFeasTol to value 1e-07
Set parameter OptimalityTol to value 1e-07
Set parameter Presolve to value 1
GurobiParams{'FeasibilityTol':1e-07 (1e-06), 'IntFeasTol':1e-07 (1e-05), 'OptimalityTol':1e-07 (1e-06), 'Presolve':1 (-1)}

All of these parameters are non-default and might hurt performance, not only Presolve 1, as discussed in this item, but also tightening tolerances (default parameters are in brackets).