[Cbc] Objective value from a callback
Gleb Belov
gleb.belov at monash.edu
Tue Oct 17 20:53:21 EDT 2017
Hi,
sometimes I get a wrong objective value in a callback.
For example, for the mps file (see below), cbc (stable/2.9) says 'Integer
solution of 17 found by strong branching after 106860 iterations and 322
nodes (40.88 seconds)' but the callback reports 22.
Files are in the folder
https://www.dropbox.com/sh/bobdmaiif3jmb3p/AAA-CgUupqhoiYvW_Yws7pFta?dl=0
In the callback, I use the code suggested by John a while ago:
if (whichEvent==solution||whichEvent==heuristicSolution) {
#ifdef STOP_EARLY
return stop; // say finished
#else
#ifdef WANT_SOLUTION
// John Forrest 27.2.16:
// check not duplicate
if (model_->getObjValue()<bestSolutionValue_) {
bestSolutionValue_ = model_->getObjValue();
// If preprocessing was done solution will be to processed model
// int numberColumns = model_->getNumCols();
const double * bestSolution = model_->bestSolution();
assert (bestSolution);
// printf("value of solution is %g\n",model_->getObjValue());
// Trying to obtain solution for the original model:
assert( model_ && model_->solver() );
double objOffset=0;
model_->solver()->getDblParam(OsiObjOffset, objOffset);
double objVal = (model_->getObjValue() - objOffset);
double bestBnd = (model_->getBestPossibleObjValue() - objOffset);
if ( 0!=cbcPreProcessPointer ) {
if ( OsiSolverInterface* cbcPreOrig =
cbcPreProcessPointer->originalModel() ) {
objVal *= cbcPreOrig->getObjSense();
bestBnd *= cbcPreOrig->getObjSense();
}
} else {
objVal *= model_->getObjSense();
bestBnd *= model_->getObjSense();
}
...
Might it be just after strong branching?
I call callCbc with options ' -solve -quit'. To reproduce the solution path
in the cbc executable in Linux, I need to add nodeStrategy fewest.
I can produce a small code example if needed. Otherwise, the whole code
with callback is open-source, see commit 330f5e6 of branch develop on
https://github.com/MiniZinc/libminizinc/commits/develop. To reproduce, run
mzn-cbc -v -s -G linear ProjectPlannertest_12_8.mzn --output-mode dzn
--output-objective -a -D fMIPdomains=false
Thank you,
Gleb
--
Dr Gleb Belov Monash University +61 3 9903 1622
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20171018/e257564e/attachment.html>
More information about the Cbc
mailing list