Open gdowdy3 opened 3 years ago
Indeed. You should be able to work around by setting the solver specific parameter as string using the Gurobi names.
Thanks for the quick reply!
Just to make sure I understand, is it the case that SetNumThreads
has no effect on Gurobi by design? Or am I only experiencing this problem because I installed Gurobi myself?
For the benefit of future generations, the work-around mentioned above is to replace
solver.SetNumThreads(4)
with
solver.SetSolverSpecificParametersAsString('Threads 4')
I have confirmed that this works. Thanks, @lperron!
For the record: up to v9.1 gurobi_interface.cc
doesn't implement SetNumThread()
but have a flag
https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/linear_solver/gurobi_interface.cc#L68-L69
Which is only use at instantiation (in the ctor)
https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/linear_solver/gurobi_interface.cc#L617-L618
While we should see (IMHO) something like in sat_interface.cc
:
https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/linear_solver/sat_interface.cc#L99
https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/linear_solver/sat_interface.cc#L294-L297
https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/linear_solver/sat_interface.cc#L106
https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/linear_solver/sat_interface.cc#L287-L288 and then setup during the solve() call https://github.com/google/or-tools/blob/86d4c543f717fa8716a9d66c25143660668bf825/ortools/linear_solver/sat_interface.cc#L142-L143
What version of OR-Tools and what language are you using? Version: v9.0.9048 Language: Python
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) Gurobi
What operating system (Linux, Windows, ...) and version? macOS Big Sur v11.6
What did you do? Steps to reproduce the behavior:
pip3 install ortools
MWE.py
. This script is very similar to the example shown here: https://developers.google.com/optimization/lp/lp_example. However, there are a few changes:python3 MWE.py
What did you expect to see
Thread count: 8 physical cores, 16 logical processors, using up to 4 threads
Thread count was 4 (of 16 available processors)
What did you see instead?
Thread count: 8 physical cores, 16 logical processors, using up to 16 threads
Thread count was 16 (of 16 available processors)
Anything else we should know about your project / environment When I was initially trying to set up ortools to use Gurobi on this machine, I had some trouble getting ortools to find Gurobi. In my efforts to solve the problem, I installed a fresh copy of Gurobi from https://www.gurobi.com. I also manually set up the GUROBI_HOME variable in my .zshenv. I believe this is the reason that I see the following whenever I run the above code.
I'm not sure whether or not this is relevant.