[Coin-discuss] OSI branchAndBound vs CBC

Michal Kaut mail at michalkaut.net
Fri May 22 08:33:42 EDT 2009


Hello Stefan,

I have a similar problem, which you helped me with previously:
http://list.coin-or.org/pipermail/cbc/2008-February/thread.html#99

Just a quick summary: I have a model in OSI and need to get solution
there as well:
   OsiCbcSolverInterface solver;
   const char *args[] = {"Cbc_Test", "-solve", "-quit"};

One option is to create a new CbcModel and solve it:
   CbcModel model(*solver.getRealSolverPtr());
   CbcMain0(model);
   CbcMain1(3, args, model);
This works fine, but how do I get copy the solution to the OSI object?
(I tried solver->getModelPtr()->setBestSolution and
solver->getModelPtr()->setObjValue, using the values from model, but it
does not work - it does not update the "best possible solution", so even
if solver knows about the optimal solution, it does not know it is
optimal..)

The other option is to work directly on the CbcModel of the OSI object:
   CbcMain0(*solver.getModelPtr());
   CbcMain1(3, args, *solver.getModelPtr());
In works fine in the sense that solver now has the optimal solution (and
knows it is optimal).
The problem with this version is that the CbcMain1 function takes more
than 3 times longer and in the first option - any idea why and how to
fix it?

I would really appreciate help with (at least) one of the above options.


Thanks,
Michal Kaut


Stefan Vigerske wrote:
> Hi,
> 
>> Ok - I need to review old postings - but simple question....
>>
>> Is OSI::branchAndBound and/or CBC::branchAndBound really B&B or is it
>> Branch-and-Cut-(and Heuristics). I.e., if it is really just B&B, I don't
>> want it. 
> 
> I think it does more than plain B&B, but not as much as the
> standalone-Cbc. OsiCbc::branchAndBound() calls
> CbcModel::branchAndBound(), as far as I see.
> 
>> I am looking for a simple interface to call a full blown MILP
>> solver.... and my model originated in OSI - but I am ok translating to
>> whatever object I need to. So, how do I do that with CBC?
> 
> You should look into examples/driver4.cpp in Cbc. It shows how to use
> the CbcMain0/CbcMain1 routines that give you access to the "full blown
> Cbc solver". It expects an OsiClp object as input.
> 
>> I'd expect something like:
>>
>> CbcModel m(*osiObject);
>> m.solve();
>>
>> ??
> 
> Yes, the CbcMain0... is somehow similar to this.
> 
> Also the following pieces of code use this way to run Cbc:
> https://projects.coin-or.org/OS/browser/trunk/OS/src/OSSolverInterfaces/OSCoinSolver.cpp#L634
> https://projects.coin-or.org/GAMSlinks/browser/stable/0.4/GAMSlinks/src/Cbc/GamsCoinCbc.cpp
> 
> If you need some kind of solver-independence (i.e., one input for many
> solvers) and only a "one-instance-one-solve", then the OS project could
> be interesting for you.
> 
> Stefan
> 




More information about the Coin-discuss mailing list