d-krupke / cpsat-primer

The CP-SAT Primer: Using and Understanding Google OR-Tools' CP-SAT Solver
https://d-krupke.github.io/cpsat-primer/
Creative Commons Attribution 4.0 International
387 stars 35 forks source link

Write a section on CP-SAT with C++ (potentially mixed with Python using PyBind11) #44

Open d-krupke opened 4 months ago

d-krupke commented 4 months ago

Sometimes, the performance of Python is simply too slow to build larger models. In this case, parts of the code can be written in C++ and integrated into Python using PyBind11. My desk neighbor Phillip Keldenich actually wrote a conan package for CP-SAT, which can be automatically build in Python using my skbuild-conan.

Could be nice to have a tutorial on how to do that.

leonlan commented 3 months ago

Do you have any examples/links for this issue? I might be interested in this for scheduling with circuit constraints. The Python model takes too long to construct the quadratic number of arc literals so moving that part into C++ would be nice to have.

d-krupke commented 3 months ago

This here is the package I have mentioned: https://github.com/d-krupke/skbuild-conan

It contains some examples on how to do such things with CGAL. I am checking with Phillip if there is a public version of the conanfile. I could then try to give you a small example that you could continue. However, likely not to happen within the next few days but maybe in a week or two.

d-krupke commented 2 months ago

It turns out that automatically building ortools via conan could be painfully slow. Of course, conan does cache the builds but it is not a beginner friendly solution. Will have to think about it a little more... :thinking: