[Cbc] Objective value from a callback

Gleb Belov gleb.belov at monash.edu
Tue Oct 17 09:48:58 EDT 2017


Hi,

sometimes I get a wrong objective value in a callback.

For example, for the attached instance, 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.

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20171017/1d756ec5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PrjPlanTest_12_8_cbcWrongObj.mps.gz
Type: application/x-gzip
Size: 200179 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20171017/1d756ec5/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ProjectPlannertest_12_8.mzn
Type: application/octet-stream
Size: 327478 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20171017/1d756ec5/attachment-0001.obj>


More information about the Cbc mailing list