CP-SAT solver python vs C++

77 views
Skip to first unread message

Alberto Manzini

unread,
Jul 6, 2024, 11:49:31 AMJul 6
to or-tools-discuss
Hi everyone, does CP-SAT solver works faster in C++ rather than Python?
Does anyone has performed some tests to verify this comparison?

By "faster" I mean both regarding to these KPIs:
- velocity on find solutions (i.e. frequency on finding next best value on objective function) = number of solutions found / time given to solver
- quality of solutions (i.e. best objective function value) = best objective function value got in the time given to solver

Thanks

Laurent Perron

unread,
Jul 6, 2024, 11:59:44 AMJul 6
to or-tools-discuss
No. The engine is the same.

The only difference is the speed to build the model. 

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/49f6fdd2-60ec-4dbe-868f-e7062e11dd54n%40googlegroups.com.

Laurent Perron

unread,
Jul 6, 2024, 12:00:20 PMJul 6
to or-tools-discuss
Caveats, callbacks can slow down solving, even significantly. 

blind.line

unread,
Jul 6, 2024, 7:40:18 PMJul 6
to or-tools...@googlegroups.com
My two cents, if you are sending a lot of data to to solver, then calling from Python can seem very slow, but if your solver runtime is on the order of tens of minutes or hours, the python part is insignificant. 

If the solver runtime is fractions of a second, then using python will indeed contribute a noticeable lag to the total run time. 

I never use C++ on my personal projects because the development time would be slow, plus I have access to all the python libraries I’m familiar with. But if you're comfortable in C++ and have a quiver of arrows for various use cases, you should use that. 

James

On Jul 6, 2024, at 09:00, 'Laurent Perron' via or-tools-discuss <or-tools...@googlegroups.com> wrote:



Alberto Manzini

unread,
Jul 8, 2024, 2:43:12 AMJul 8
to or-tools-discuss
Thanks!
Reply all
Reply to author
Forward
0 new messages