[Cbc] Multi-threading: command line works, programmatically fails

Serena Cortopassi s.cortopassi at elabor.biz
Mon Nov 24 10:55:12 EST 2014


Hi,

I need to use multi-threading with Cbc and I've found some answers here in
the mailing list, anyway it doesn't work. Maybe have I done something
wrong?

I configured cbc using:

s.cortopassi at pergamo:~/coin-FlopCpp/Cbc$ ./configure CFLAGS='-m64 -O3' 
--enable-cbc-parallel --enable-debug -C --prefix=/usr/local

Now, using the command line executable I can set the number of threads and
it seems to work:

s.cortopassi at pergamo:~/coin-FlopCpp/Cbc$ cbc
Welcome to the CBC MILP Solver
Version: 2.8.8
Build Date: Nov 19 2014

CoinSolver takes input from arguments ( - switches to stdin)
Enter ? for list of commands or help
Coin:threads 2
threads was changed from 0 to 2

But I need to do the same thing programmatically, not by command line.
I've tried with two solutions I've found here:
1. The first one using setNumberThreads:

  OsiCbcSolverInterface *si = new OsiCbcSolverInterface();
  CbcModel model(si);
  model.setNumberThreads(2);

I obtain the same solution than using 1 thread and it takes the same time.
Is it normal? In the ouput lines while processing it never mention the
second thread.

2. The second one using CbcMain0/1:

  OsiCbcSolverInterface *si = new OsiCbcSolverInterface();

  CbcModel model(*(si->getRealSolverPtr()));

  const char *args[17] = {"dvf",
  "-threads", "2",
  "-heur", "off",
  "-proximity", "on",
  "-DivingC", "on",
  "-cuts", "off",
  "-gomory", "root",
  "-mixed", "on",
  "-solve", "-quit"};
  CbcMain0(*(si->getModelPtr()));
  CbcMain1(17,args,*si->getModelPtr());

But I obtain two errors (no match for threads and model not valid):

Welcome to the CBC MILP Solver
Version: 2.8.8
Build Date: Jul 14 2014
Revision Number: 2047

command line - dvf -threads 2 -heur off -proximity on -DivingC on -cuts
off -gomory root -mixed on -solve -quit (default strategy 1)
No match for threads - ? for list of commands
No match for 2 - ? for list of commands
Option for heuristicsOnOff changed from on to off
Option for proximitySearch changed from off to on
Option for DivingCoefficient changed from off to on
Option for cutsOnOff changed from on to off
Option for gomoryCuts changed from off to root
Option for mixedIntegerRoundingCuts changed from off to on
** Current model not valid
Total time (CPU seconds):       0.00   (Wallclock seconds):       0.00

FlopCpp: Number of constraint blocks: 15
FlopCpp: Number of individual constraints: 2904
FlopCpp: Number of variable blocks: 11
........


Do you have any suggestion?
Thank you very much,

Serena





More information about the Cbc mailing list