<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&&...)</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. 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 <ks15@icparc.ic.ac.uk></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
</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 "OsiCbcSolverInterface.hpp"<br>
typedef OsiCbcSolverInterface OsiXxxSolverInterface;<br>
#endif<br>
<br>
To solve a MIP problem, I originally had:<br>
<br>
lpd->lp->initialSolve());<br>
lpd->lp->branchAndBound());<br>
<br>
where lpd->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>
OsiSolverInterface * mipsolver = lpd->lp;<br>
CglPreProcess process;<br>
<br>
mipsolver = process.preProcess(*(lpd->lp), false, 5);<br>
mipsolver->resolve();<br>
<br>
CbcModel model(*mipsolver);<br>
<br>
instead of<br>
<br>
solver1.initialSolve();<br>
// Reduce printout<br>
solver1.setHintParam(OsiDoReducePrint,true,OsiHintTry);<br>
// See if we want preprocessing<br>
OsiSolverInterface * solver2=&solver1;<br>
CglPreProcess process;<br>
if (preProcess) {<br>
/* Do not try and produce equality cliques and<br>
do up to 5 passes */<br>
solver2 = process.preProcess(solver1,false,5);<br>
if (!solver2) {<br>
printf("Pre-processing says infeasible\n");<br>
exit(2);<br>
}<br>
solver2->resolve();<br>
}<br>
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>
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>
OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*>
(model.solver());<br>
<br>
// go faster stripes<br>
if (osiclp->getNumRows()<300&&osiclp->getNumCols()<500)
{<br>
//osiclp->setupForRepeatedUse(2,0);<br>
<br>
osiclp->setupForRepeatedUse(0,0);<br>
} <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>