[Cbc] getting solution to original problem from Cbc/Clp

Kish Shen kisshen at cisco.com
Mon Oct 22 12:56:52 EDT 2007


Hi John,

Thanks again for your help!

John J Forrest wrote:
> 
> Kish,
> 
> It sounds as if you are using presolve rather than CglPreProcess.  This 
> could give wrong results as you describe.
> 
> Look at Cbc/examples/sample2.cpp and try with PREPROCESS defined to 1 or 
> 2 to see two ways of using CglPreProcess.
> 

I used OsiSolverInterface's setHintParam() to set OsiDoPreSolveInInitial 
and OsiPreSolveInResolve, as well as using CglPreProcess. This is in the 
genric code part, which is intended for any solver I am using via OSI. 
For MIP problems and CBC, I then do CBC specific calls to do the MIP 
solve, including using CglPreProcess.

I am actually using some version of the example2.cpp to do the MIP 
solving, but it is probably quite an old version of the code (more than 
one year old, it does not have this PREPROCESS def), and I probably made 
various changes to it.

I now explicitly turn off OsiDoPresolveInInitial and 
OsiPresolveInResolve for MIP problems and when using CLP/CBC (it is 
still set initially in the generic code, so that presolve will still be 
switched on if requested with other solvers.

This got pass my previous problem, where some simple checks detected 
problems with the solution values returned and aborted. I don't get the 
abort anymore, but I still have a much smaller column size when I call
CbcModel's getNumCols (compared to OsiSolverInterface's). This is done 
after a call to postProcess().

Is something still wrong, or is getNumCols expected to return the 
smaller column size? I am getting the solution array assuming it has the 
size returned by OsiSolverInterface's getNumCols().

> As to your questions.
> 
> 1)  The solver can in some circumstances not have an integer solution - 
> bestSolution is what is needed but it must go through post processing.

I should have mentioned that sometimes the solving was timed out, so the 
MIP solve may not have completed. In all cases, there is a call to 
postProcess().

I am still getting some errors during the checking phase now, but 
because the column number is still much smaller for the CbcModel, I did 
not look at these checks in more detail yet.

Thanks again,

Kish

> 2) The result should be correct for problem with all integer variables 
> fixed to correct values.
> 
> 
> John Forrest
> 
> 
> *Kish Shen <kisshen at cisco.com>*
> Sent by: cbc-bounces at list.coin-or.org
> 
> 10/19/2007 12:03 PM
> 
> 	
> To
> 	cbc at list.coin-or.org
> cc
> 	
> Subject
> 	[Cbc] getting solution to original problem from Cbc/Clp
> 
> 
> 	
> 
> 
> 
> 
> 
> Hi,
> 
> I am using CBC with CLP as the linear solver. CLP is accessed via OSI
> i.e. OsiClpSolverInterface), but CBC is accessed directly, instead of
> via OSI.
> 
> I have been obtaining the solution state for MIP problems via the OSI
> calls, e.g. getColSolution(), getRowPrice(), etc.. One of our users
> reported that some of the solution is incorrect, e.g. variables that
> should be integers are not, and some constraints are violated.
> 
> I suspected that this is because the OSI calls are via
> OsiClpSolverInterface, and so I am obtaining the state from the most
> recent LP relaxation, rather than the most recent MIP solution. I
> therefore changed the code to obtain the solution state via Cbc calls,
> for example, bestSolution() of CbcModel instead of getColSolution().
> 
> Unfortunately, in this case, the number of columnssiz in the problem
> seems to be much smaller: in one example, the original problem had 945
> columns, and the MIP solution of the problem has only  205 columns. I
> assume this is because presolve reduced the problem, and bestSolution()
> returns the solution for the presolved matrix.
> 
> Questions:
> 
> 1) Am I correct that OSIClpSolverInterface's methods, such as
> getColSolution(), is returning the state from the LP relaxation, rather
> than the MIP solution? [If not, then there is something wrong with the
> MIP solution produced]
> 
> 2) How can I obtain the MIP solution state (solution values, row price,
> row activity, reduced cost [and basis status for the LP relaxation that
> produced the MIP solution, if this is available], for the original
> problem (and not the presolved problem)?
> 
> Thanks in advance for any help/information!
> 
> Cheers,
> 
> Kish Shen
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cbc
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cbc


More information about the Cbc mailing list