Thanks All.<br><br>This <br> const char *args[] = {"Cbc_Test", "-solve", "-quit"};<br> CbcModel model(*solver.getRealSolverPtr());<br> CbcMain0(model);<br><div class="im"> CbcMain1(3, args, model);<br>
<br>seems to work much better than OsiCbc::branchAndBound( ) !<br>
<br>This is a very odd construction. Maybe I asked this before, but why don't we just have a CbcModel::model.solve( ) method? Why is there not some simple API like this for solving a MILP with CBC?<br><br>Moreover - for OSI users, why don't we have an OsiCbc::solveMilp( ) method? The base class can have solveMilp( ) virtual and for those OsiXxx's that can solve MILPs (OsiCpx, OsiXpr, OsiCbc, ...), it gets derived, else it returns an error. I understand the reluctance to add MILP support in OSI when OSI2 was being discussed -- but that was many years ago. As an "interim" fix, can we at least make OSI work for MILPs - since many people are already using them to define and (try to) solve MILPs.<br>
<br>Thanks,<br>Matt<br></div><br><br><div class="gmail_quote"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<div class="im"><br>
> I have a similar problem, which you helped me with previously:<br>
> <a href="http://list.coin-or.org/pipermail/cbc/2008-February/thread.html#99" target="_blank">http://list.coin-or.org/pipermail/cbc/2008-February/thread.html#99</a><br>
><br>
> Just a quick summary: I have a model in OSI and need to get solution<br>
> there as well:<br>
> OsiCbcSolverInterface solver;<br>
<br>
</div>Better use "OsiClpSolverInterface solver;" here.<br>
I think Cbc do some special stuff if the instance comes as an OsiClp object.<br>
<div class="im"><br>
> const char *args[] = {"Cbc_Test", "-solve", "-quit"};<br>
><br>
> One option is to create a new CbcModel and solve it:<br>
> CbcModel model(*solver.getRealSolverPtr());<br>
> CbcMain0(model);<br>
> CbcMain1(3, args, model);<br>
> This works fine, but how do I get copy the solution to the OSI object?<br>
> (I tried solver->getModelPtr()->setBestSolution and<br>
> solver->getModelPtr()->setObjValue, using the values from model, but it<br>
> does not work - it does not update the "best possible solution", so even<br>
> if solver knows about the optimal solution, it does not know it is<br>
> optimal..)<br>
<br>
</div>CbcModel creates a copy of the Osi interface that you give to it and<br>
works on this one. So maybe using the OsiSolverInterface* from<br>
model.solver() will work?<br>
Or you fix integer variables to the solution in your Osi, try to copy<br>
the basis from model.solver() as well, and do a resolve() in your Osi.<br>
<div class="im"><br>
> The other option is to work directly on the CbcModel of the OSI object:<br>
> CbcMain0(*solver.getModelPtr());<br>
> CbcMain1(3, args, *solver.getModelPtr());<br>
> In works fine in the sense that solver now has the optimal solution (and<br>
> knows it is optimal).<br>
> The problem with this version is that the CbcMain1 function takes more<br>
> than 3 times longer and in the first option - any idea why and how to<br>
> fix it?<br>
<br>
</div>Maybe the way the CbcModel is setup in OsiCbc is different.<br>
<div class="im"><br>
Stefan<br>
<br>
--<br>
Stefan Vigerske<br>
Humboldt University Berlin, Numerical Mathematics<br>
<a href="http://www.math.hu-berlin.de/%7Estefan" target="_blank">http://www.math.hu-berlin.de/~stefan</a><br>
<br>
</div><div><div></div><div class="h5">_______________________________________________<br>
Coin-discuss mailing list<br>
<a href="mailto:Coin-discuss@list.coin-or.org">Coin-discuss@list.coin-or.org</a><br>
<a href="http://list.coin-or.org/mailman/listinfo/coin-discuss" target="_blank">http://list.coin-or.org/mailman/listinfo/coin-discuss</a><br>
</div></div></blockquote></div><br>