How to set number of threads in OR-Tools proto interface?

Viewed 147

We are using the Java MP proto interface in order to have access to indicator constraints. The solve phase of our problems typically take several hours to run given the high number of binary variables.

The proto interface utilizes a MPModelRequest which contains the Model and SolverType and is then passed to the static method MPSolver.solveWithProto(mpModelRequest).

The number of threads cannot be specified for the request and the solveWithProto method is static, so we would like to know if instantiating an MPSolver and setting the number of threads would actually have the desired effect.

Original code : 1 thread

final MPModelRequest mpModelRequest = MPModelRequest.newBuilder()
                .setEnableInternalSolverOutput(true)
                .setSolverType(MPModelRequest.SolverType.SCIP_MIXED_INTEGER_PROGRAMMING)
                .setModel(model)
                .build();

MPSolutionResponse response = MPSolver.solveWithProto(mpModelRequest); 

Creating an MPSolver : will it make use of multiple threads even though the method is static?

MPSolver mpSolver = MPSolver.createSolver(MPModelRequest.SolverType.SCIP_MIXED_INTEGER_PROGRAMMING.toString());
mpSolver.setNumThreads(8);
MPSolutionResponse response = mpSolver.solveWithProto(mpModelRequest); 
1 Answers

SCIP parallelism is broken and disabled. It brings very little speedup in general anyway.

If your problem is integral only, you can use the CP-SAT backend. It will benefit from 8+ more threads.

Related