[Cbc] cbc.exe vs. Cbc API
Michal Kaut
mail at michalkaut.net
Thu Feb 7 09:42:21 EST 2008
Hello,
thanks for the help, I have working, almost as I wanted.
Based on your suggestion, I wrote the following simple program:
-------------------------------------------------------------------
#define VERSION 4
int main()
{
#if VERSION == 1
OsiClpSolverInterface solver;
#else
OsiCbcSolverInterface solver;
#endif
solver.readMps("MIP_model");
const char *args[] = {"Cbc_Test", "-solve", "-quit"};
#if VERSION <= 2
CbcModel model(solver);
CbcMain0(model);
CbcMain1(3, args, model);
#endif
#if VERSION == 3
CbcModel model(*solver.getRealSolverPtr());
CbcMain0(model);
CbcMain1(3, args, model);
#endif
#if VERSION == 4
CbcMain0(*solver.getModelPtr());
CbcMain1(3, args, *solver.getModelPtr());
#endif
std::cout << "Done. Optimal objective = " << solver.getObjValue();
return 0;
}
-------------------------------------------------------------------
"VERSION 1" is basically the code you sent me.
- This gives the same output as cbc.exe - good.
- There are, however, two issues here (for me):
- It uses OsiClp, while in my code I use a OsiCbc object.
- The original 'solver' object does not see the solution, so the
final line prints zero.
"VERSION 2" is the same code, except that it uses OsiCbc
- This version builds, but crashes on execution (in CbcMain0).
"VERSION 3" is like V1, except that is uses OsiCbc. It produces exactly
the same output as V1, but also retains the second disadvantage of not
passing the solution to the 'solver' object.
"VERSION 4" solves both the problems from V1, but the solution takes 3x
as long (116s vs. 40s) and uses 1164 nodes, compared to 247 of V1/V3.
So, what I would like to know, is this:
- Is there something inherently wrong with V4 that would explain the
difference in solution time, or is it just a coincidence (caused for
example by the fact that OsiCbc passes some options to the solver)?
- Is there some other way to fix V3, so that the solution gets passed to
the original OsiCbc object 'solver'?
Thanks a lot in advance.
Regards,
Michal
PS: If someone wants to build this, I had to link CbcSolver before Cbc,
otherwise it wouldn't build (on gcc 4.2).
More information about the Cbc
mailing list