[Cbc] best way of solving a problem in OsiCbc?

Michal Kaut mail at michalkaut.net
Thu Nov 12 05:27:48 EST 2009


Hello,

I have been trying different ways of solving a MIP  problem, which I 
have in an OsiCbc object. I observe very varying solution times and 
would appreciate some feedback.

First some info about the problem: it is a kind of matching problem, 
with N*N binary variables, 2*N*N continuous variables and 2*N+N*N 
constraints. When saved as MPS and solved using the stand-alone cbc 2.4 
binary, it takes 23.8s with default settings, 4.4s with "-heur off -cuts 
off" and 2.8s with "-heur off -cuts off - DivingF on". (I get similar 
result with DivingP and DivingV).

Now, to the code. I have 'CbcOsiSolverInterface *p2solver' pointing to 
the Osi object, created by FlopC++. The times are measured by CoinTimer.

1. simple call to the B&B solver - this is called by Flop's solve():
   p2solver->branchAndBound();
time = 15.6s

2. use CbcMain, to get the simply interface of the standalone cbc:
   const int nCbcArgs = 9;
   const char *args[nCbcArgs] = {
     "copula_MIP", "-heur", "off", "-DivingF", "on", "-cuts", "off",
     "-solve", "-quit"
   };
   CbcMain(nCbcArgs, args, *(p2solver->getModelPtr()));
time = 10s

3. just like 2., but on a temp. copy of the model:
   CbcModel tmpModel(*(p2solver->getRealSolverPtr()));
   CbcMain(nCbcArgs, args, tmpModel);
using the same arguments as above; the solution is then copied to the 
original Osi model, by fixing column bounds equal to the sol. and 
copying the basis using setBestSolutionBasis()
time = 6.7s  (including copying of the solution; CbcMain1 says 5.8s)

4. the same temp. model as in 3, but solved by branchAndBound():
   CbcModel tmpModel(*(p2solver->getRealSolverPtr()));
   tmpModel.branchAndBound();
time = 3.1s  (again all-inclusive)

5. just like 4., but call CbcMain0 prior to B&B:
   CbcModel tmpModel(*(p2solver->getRealSolverPtr()));
   CbcMain0(tmpModel);
   tmpModel.branchAndBound();
time = 2.1s  (all-inclusive)

6. like 4, but on a temp. OsiCbcSolverInterface:
   OsiCbcSolverInterface tmpOsi(p2solver);
   tmpOsi.branchAndBound();
time = 2.9s  (all-inclusive)


For me, the strangest thing is that solving a temp. copy of the model is 
consistently and significantly faster than solving the original model. 
Is this specific to Osi objects created by FlopC++? (I have observed 
this with another FlopC++ model, using older version of Cbc - so I don't 
think it is model- or Cbc-version-specific.)

And the big question, of course, is what is the best/recommended way of 
solving a OsiCbc model?
I would also like to know if some of the presented methods are 
fundamentally flawed/dangerous and why?


Thanks a lot in advance and sorry for the long post

Michal



More information about the Cbc mailing list