<br><font size=2 face="sans-serif">Kish,</font>
<br>
<br><font size=2 face="sans-serif">After the dynamic cast there should
have been a test if (osiclp&amp;&amp;...)</font>
<br>
<br><font size=2 face="sans-serif">OsiCbc was just a mistake on my part
when I indulged someones' whim.</font>
<br>
<br><font size=2 face="sans-serif">If you send me log files I can give
some suggestions. &nbsp;It may be to do with CbcStrategy where you are
getting a default strategy which may override something.</font>
<br>
<br><font size=2 face="sans-serif">John Forrest</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Kish Shen &lt;ks15@icparc.ic.ac.uk&gt;</b>
</font>
<br><font size=1 face="sans-serif">Sent by: coin-discuss-bounces@list.coin-or.org</font>
<p><font size=1 face="sans-serif">08/17/2005 01:51 PM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
Discussions about open source software for Operations Research &nbsp; &nbsp;
&nbsp; &nbsp;</font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td valign=top><font size=1 face="sans-serif">coin-discuss@list.coin-or.org</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">[Coin-discuss] Using CBC
with OSI</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>Hi,<br>
<br>
I have been trying out Osi as an interface to different MP solvers. One
of<br>
these is Cbc, compiled with Clp as the linear solver. <br>
<br>
To allow for different solvers with the same code, I use the<br>
OsiXxxSolverInterface declaration as suggested in the tutorial<br>
documentations:<br>
<br>
#ifdef COIN_USE_CBC<br>
#include &quot;OsiCbcSolverInterface.hpp&quot;<br>
typedef OsiCbcSolverInterface OsiXxxSolverInterface;<br>
#endif<br>
<br>
To solve a MIP problem, I originally had:<br>
<br>
lpd-&gt;lp-&gt;initialSolve());<br>
lpd-&gt;lp-&gt;branchAndBound());<br>
<br>
where lpd-&gt;lp is a * OsiXxxSolverInterface.<br>
<br>
I also tried running the various drivers for the `testit' test program
in<br>
Cbc's sample directory, and I noticed that the driver sample2 seem to perform<br>
significantly better than the results I am getting with the above simple<br>
call to branchAndBound() for the more difficult problems I tested. <br>
<br>
I ran into some problems when I tried to adapt the sample2 code for my
own<br>
program, and I am hoping that I can get some help with this. Thanks in<br>
advance for any help/information on this!<br>
<br>
<br>
In my program, I tried to use as much of the sample2.cpp code as possible,<br>
with only the initial code to get the solver being different:<br>
<br>
<br>
 &nbsp; &nbsp;OsiSolverInterface * mipsolver = lpd-&gt;lp;<br>
 &nbsp; &nbsp;CglPreProcess process;<br>
<br>
 &nbsp; &nbsp;mipsolver = process.preProcess(*(lpd-&gt;lp), false, 5);<br>
 &nbsp; &nbsp;mipsolver-&gt;resolve();<br>
<br>
 &nbsp; &nbsp;CbcModel model(*mipsolver);<br>
<br>
instead of<br>
<br>
 &nbsp;solver1.initialSolve();<br>
 &nbsp;// Reduce printout<br>
 &nbsp;solver1.setHintParam(OsiDoReducePrint,true,OsiHintTry);<br>
 &nbsp;// See if we want preprocessing<br>
 &nbsp;OsiSolverInterface * solver2=&amp;solver1;<br>
 &nbsp;CglPreProcess process;<br>
 &nbsp;if (preProcess) {<br>
 &nbsp; &nbsp;/* Do not try and produce equality cliques and<br>
 &nbsp; &nbsp; &nbsp; do up to 5 passes */<br>
 &nbsp; &nbsp;solver2 = process.preProcess(solver1,false,5);<br>
 &nbsp; &nbsp;if (!solver2) {<br>
 &nbsp; &nbsp; &nbsp;printf(&quot;Pre-processing says infeasible\n&quot;);<br>
 &nbsp; &nbsp; &nbsp;exit(2);<br>
 &nbsp; &nbsp;}<br>
 &nbsp; &nbsp;solver2-&gt;resolve();<br>
 &nbsp;}<br>
 &nbsp;CbcModel model(*solver2);<br>
<br>
====<br>
The rest of the code, until the call to branchAndBound(), was just copied<br>
from sample2.cpp.<br>
<br>
1) is the first call to initialSolve() usefull/necessary? The preprocessing<br>
seems to solve the problem also.<br>
<br>
2) I didn't check if the problem was infeasible after preprocessing, as
I<br>
 &nbsp; don't expect the test cases I was using to be infeasible.<br>
<br>
When I tried running this code, the program seg faults when running<br>
<br>
 &nbsp;OsiClpSolverInterface * osiclp = dynamic_cast&lt; OsiClpSolverInterface*&gt;
(model.solver());<br>
<br>
 &nbsp;// go faster stripes<br>
 &nbsp;if (osiclp-&gt;getNumRows()&lt;300&amp;&amp;osiclp-&gt;getNumCols()&lt;500)
{<br>
 &nbsp; &nbsp;//osiclp-&gt;setupForRepeatedUse(2,0);<br>
<br>
 &nbsp; &nbsp;osiclp-&gt;setupForRepeatedUse(0,0);<br>
 &nbsp;} <br>
<br>
<br>
It seems to happen when calling getNumRows(). I assume the problem is<br>
related to casting the model.solver() to an OsiClpSolverInterface *, when<br>
what I have is OsiCbcSolverInterface *. Is there anyway I can do this<br>
casting correctly?<br>
<br>
I commented out this code and was able to compile and run the<br>
code. However, the timings I get is much worse than running testit with<br>
sample2, across a range of programs. For example, for the MIPLIB problem<br>
air04, I aborted the execution of my program when it had already spent
more<br>
than 100 times longer than the time to solve the problem with<br>
testit/sample2. I was very surprised by this, as I had expected similar<br>
timngs (except maybe when the problem is small and the above call to<br>
setupForRepeatedUse() was made).<br>
<br>
I suspected that because in my code, I actually create and fill in the<br>
problem matrix rather than reading the problem in as an MPS file, then
the<br>
column/row orders might be different, and this might lead to the<br>
differences, but I would not expect this would make my timings to be<br>
more or less consistently worse than those of testit/sample2. <br>
<br>
To try to get round this possible rearrangement of the columns and rows,
I <br>
wrote out a MPS file of the problem in my program, and ran testit on this<br>
MPS file. Am I correct in thinking that the row/column orders are preserved<br>
by the MPS format? In any case, I still get the same timing differences.<br>
<br>
Any ideas on why there is such a big difference in the solving times? Am
I<br>
missing something?<br>
<br>
Again, thanks in advance for any help/information!<br>
<br>
Cheers,<br>
<br>
Kish Shen<br>
IC-Parc<br>
Imperial College London<br>
U.K.<br>
_______________________________________________<br>
Coin-discuss mailing list<br>
Coin-discuss@list.coin-or.org<br>
http://list.coin-or.org/mailman/listinfo/coin-discuss<br>
</tt></font>
<br>