Closed lucafesta closed 2 years ago
just switch to C++. Python protobufs are very slow and not MT safe.
@lperron There is another way to make parallelization in python or an example of the C++ code with a pywrapper in python?
Look at pybind11. Examples are in ortools/graph/python
Python 3.8 / CP-SAT: ortools==9.3
I'm facing a time issue in a jobshop scheduling problem due to an huge number of intervals and constraints. As for I have written the problem, the very big part of the time is spent in the creation of "NewIntervalVars" and various constraints on them. This part could be parallelized because the interaction between intervals is made all in the end of the program. First I try to use a multiprocess on the same model instance, and I had no improvements (probably due to a massive access of the same memory space?). Then I decide to create a new model for each thread and then concatenate them all toghether using the protobuf:
This solution resolve the time issue, but the final model doesn't work correcly: in fact I'm not able to access to the variable merged in the final model and create constraints that use them all.
In the example below there is a code that replicates what I'm trying to do and where it fails.
There is any way to access the variabile in the model using the name (like model.something("variable_name") ) and use it to create the new constraints? Or there are other possible solutions?