Search code examples
pythonor-toolscp-sat

CPU multithreading for OR-tools CP-SAT


I have developed a model in OR-tools using its CP-SAT solver (python). The model seeks to determine some optimal order which can be considered a sorft of TSP problem. This has been working well, and might be used by others in the form of a .exe.

From what i've read and experienced, CP-SAT benefits from more cores/threads.I currently use a (laptop) i5-1335u, 8 threads which has reasonable speed. I am wondering about the following;

Question 1: would a (desktop) CPU with a higher clock speed and increased number of threads (e.g. 16) yield significant reduction in computation time? Which of the two has the most benefit?

Question 2: Should there be a focus on something like 4/8/16 threads, or does any number threads > 1 improve speed?

Thanks in advance.

P.S, I use OR-tools TSP as an initial solution to the problem, oftenwise the CP-SAT is able to find a marginally better solution, therefore I don't want to resort to merely the TSP implementation.

I tried the model on another device with an i5-1135G7 which produced similar results in terms of computation time. I do not have acces to any other hardware as of now.


Solution

  • I wrote a section on this:

    https://github.com/google/or-tools/blob/stable/ortools/sat/docs/troubleshooting.md#improving-performance-with-multiple-workers

    Tldr: go to 16 workers