pulp icon indicating copy to clipboard operation
pulp copied to clipboard

Allow for the control of the number of threads when using the python API for CPLEX

Open Joao-Alves opened this issue 3 years ago • 2 comments

Describe the new feature

When creating a solver instance of CPLEX_PY I would like to be able to control the number of threads that the model uses, because some small problems that require a lot of iterations to solve benefit from using less threads.

Additional info

Is your feature request related to an issue? Please include the issue number.

Didn't find any

Does this feature exist in another product or project? Please provide a link.

The CPLEX API allows for this, as you can see in the documentation. https://www.ibm.com/docs/en/icos/12.8.0.0?topic=parameters-global-thread-count

Implementation suggestion

When creating the class CPLEX_PY allow for an optional parameter called nthreads with a default value of 0 (also the default value of CPLEX). When calling the function buildSolverModel at the end call a function that would run the command self.solverModel.parameters.threads.set(nthreads)

Joao-Alves avatar Jun 21 '21 13:06 Joao-Alves

do you feel like doing a PR with the change? check this part https://github.com/coin-or/pulp/blob/de4dbb7cc3a9ed2bd0e88fe9e45f7a66571bad1f/pulp/apis/cplex_api.py#L432-L463 to see how we feed the cplex library with the current configuration.

pchtsp avatar Aug 11 '21 17:08 pchtsp

I've created a pull request with this change a few small changes that I fell would improve pulp

Joao-Alves avatar Apr 19 '22 15:04 Joao-Alves

I've adapted the PR above to introduce only the threads option.

f-kretschmer avatar Jul 05 '23 13:07 f-kretschmer