<div dir="ltr"><div>Hi,</div><div><br></div><div>sometimes I get a wrong objective value in a callback.</div><div><br></div><div>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.</div><div><br></div><div>Files are in the folder <a href="https://www.dropbox.com/sh/bobdmaiif3jmb3p/AAA-CgUupqhoiYvW_Yws7pFta?dl=0">https://www.dropbox.com/sh/bobdmaiif3jmb3p/AAA-CgUupqhoiYvW_Yws7pFta?dl=0</a></div><div><br></div><div>In the callback, I use the code suggested by John a while ago:</div><div><br></div><div><font face="monospace, monospace">    if (whichEvent==solution||whichEvent==heuristicSolution) {</font></div><div><font face="monospace, monospace">#ifdef STOP_EARLY</font></div><div><font face="monospace, monospace">      return stop; // say finished</font></div><div><font face="monospace, monospace">#else</font></div><div><font face="monospace, monospace">#ifdef WANT_SOLUTION</font></div><div><font face="monospace, monospace">  // John Forrest  27.2.16:</font></div><div><font face="monospace, monospace">      // check not duplicate</font></div><div><font face="monospace, monospace">      if (model_->getObjValue()<bestSolutionValue_) {</font></div><div><font face="monospace, monospace">      bestSolutionValue_ = model_->getObjValue();</font></div><div><font face="monospace, monospace">      // If preprocessing was done solution will be to processed model</font></div><div><font face="monospace, monospace">      //       int numberColumns = model_->getNumCols();</font></div><div><font face="monospace, monospace">      const double * bestSolution = model_->bestSolution();</font></div><div><font face="monospace, monospace">      assert (bestSolution);</font></div><div><font face="monospace, monospace">      //       printf("value of solution is %g\n",model_->getObjValue());</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">      // Trying to obtain solution for the original model:</font></div><div><font face="monospace, monospace">      assert( model_ && model_->solver() );</font></div><div><font face="monospace, monospace">      double objOffset=0;</font></div><div><font face="monospace, monospace">      model_->solver()->getDblParam(OsiObjOffset, objOffset);</font></div><div><font face="monospace, monospace">      double objVal = (model_->getObjValue() - objOffset);</font></div><div><font face="monospace, monospace">      double bestBnd = (model_->getBestPossibleObjValue() - objOffset);</font></div><div><font face="monospace, monospace">      if ( 0!=cbcPreProcessPointer ) {</font></div><div><font face="monospace, monospace">        if ( OsiSolverInterface* cbcPreOrig = cbcPreProcessPointer->originalModel() ) {</font></div><div><font face="monospace, monospace">          objVal *= cbcPreOrig->getObjSense();</font></div><div><font face="monospace, monospace">          bestBnd *= cbcPreOrig->getObjSense();</font></div><div><font face="monospace, monospace">        }</font></div><div><font face="monospace, monospace">      } else {</font></div><div><font face="monospace, monospace">        objVal *= model_->getObjSense();</font></div><div><font face="monospace, monospace">        bestBnd *= model_->getObjSense();</font></div><div><font face="monospace, monospace">      }</font></div><div><font face="monospace, monospace">...</font></div><div><br></div><div>Might it be just after strong branching?</div><div><br></div><div>I call callCbc with options ' -solve -quit'. To reproduce the solution path in the cbc executable in Linux, I need to add nodeStrategy fewest.</div><div><br></div><div>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 <a href="https://github.com/MiniZinc/libminizinc/commits/develop">https://github.com/MiniZinc/libminizinc/commits/develop</a>. To reproduce, run </div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">mzn-cbc -v -s -G linear ProjectPlannertest_12_8.mzn --output-mode dzn --output-objective -a -D fMIPdomains=false</font></div><div><br></div><div>Thank you,</div><div>Gleb</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Dr Gleb Belov       Monash University     
 +61 3 9903 1622<br>
</div></div></div></div></div></div></div></div></div></div>
</div>