ILOINCUMBENTCALLBACK2(getFirstSolInfo, IloInt&, cpt, IloNum, startTime){ if (cpt <1){ std::cout << "Sol n°" << cpt+1 << " obj: \t" << getObjValue() << std::endl; std::cout << "Sol n°" << cpt+1 << " time: \t" << getCplexTime()-startTime << std::endl; std::cout << "Sol n°" << cpt+1 << " gap: \t" << getMIPRelativeGap() << std::endl; cpt=cpt+1; } }
ILOMIPINFOCALLBACK5(timeLimitCallback, IloCplex, cplex, IloBool, aborted, IloNum, timeStart, IloNum, timeLimit, IloNum, acceptableGap) { if ( !aborted && hasIncumbent() ) { IloNum gap = 100.0 * getMIPRelativeGap(); IloNum timeUsed = cplex.getCplexTime() - timeStart; if ( timeUsed > 1 ) getEnv().out() << timeUsed << endl; if ( timeUsed > timeLimit && gap < acceptableGap ) { getEnv().out() << endl << "Good enough solution at " << timeUsed << " sec., gap = " << gap << "%, quitting." << endl; aborted = IloTrue; abort(); } } }