[Coin-discuss] OSI branchAndBound vs CBC
Stefan Vigerske
stefan at math.hu-berlin.de
Fri May 22 09:11:58 EDT 2009
Hi,
> 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;
Better use "OsiClpSolverInterface solver;" here.
I think Cbc do some special stuff if the instance comes as an OsiClp object.
> 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..)
CbcModel creates a copy of the Osi interface that you give to it and
works on this one. So maybe using the OsiSolverInterface* from
model.solver() will work?
Or you fix integer variables to the solution in your Osi, try to copy
the basis from model.solver() as well, and do a resolve() in your Osi.
> 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?
Maybe the way the CbcModel is setup in OsiCbc is different.
Stefan
--
Stefan Vigerske
Humboldt University Berlin, Numerical Mathematics
http://www.math.hu-berlin.de/~stefan
More information about the Coin-discuss
mailing list