fix cbc threads

This commit is contained in:
Laurent Perron
2019-04-26 12:47:42 +02:00
parent c14296c6ef
commit f956f2ea1c

View File

@@ -383,10 +383,10 @@ MPSolver::ResultStatus CBCInterface::Solve(const MPSolverParameters& param) {
// Special way to set the relative MIP gap parameter as it cannot be set
// through callCbc.
model.setAllowableFractionGap(relative_mip_gap_);
// Num threads.
model.setNumberThreads(num_threads_);
// NOTE: Trailing space is required to avoid buffer overflow in cbc.
int return_status = callCbc("-solve ", model);
int return_status = num_threads_ == 1 ?
callCbc("-solve ", model) :
callCbc(absl::StrCat("-threads ", num_threads_, " -solve "), model);
const int kBadReturnStatus = 777;
CHECK_NE(kBadReturnStatus, return_status); // Should never happen according
// to the CBC source