示例#1
0
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;
  }    
}
示例#2
0
ILOMIPINFOCALLBACK5(loggingCallback,
                    IloNumVarArray, vars,
                    IloNum,         lastLog, 
                    IloNum,         lastIncumbent,
                    IloNum,         startTime,
                    IloNum,         startDetTime)
{
   int newIncumbent = 0;
   int nodes = getNnodes();

   if ( hasIncumbent()                                  && 
        fabs(lastIncumbent - getIncumbentObjValue())
              > 1e-5*(1.0 + fabs(getIncumbentObjValue())) ) {
      lastIncumbent = getIncumbentObjValue();
      newIncumbent = 1;
   }
     
   if ( nodes >= lastLog + 100  ||  newIncumbent ) {  

      if ( !newIncumbent )  lastLog = nodes;
      getEnv().out() << "Time = " << getCplexTime() - startTime
                     << "  Dettime = " << getDetTime() - startDetTime
                     << "  Nodes = " << nodes
                     << '(' << getNremainingNodes() << ')'
                     << "  Best objective = " << getBestObjValue();

      if ( hasIncumbent() ) {
         getEnv().out() << "  Incumbent objective = " << getIncumbentObjValue()
                        << endl;
      }
      else {
         getEnv().out() << endl;
      }

   }
   if ( newIncumbent ) {
      IloNumArray val(vars.getEnv());
      getIncumbentValues(val, vars);
      val[0] = getIncumbentValue(vars[0]);
      getEnv().out() << "New incumbent variable values: " << endl
                     << val << endl;
      val.end();
   }
}
示例#3
0
ILOMIPINFOCALLBACK5(loggingCallback,
                    IloNumVarArray, vars,
                    IloNum,         lastDettime, 
                    IloNum,         lastIncumbent,
                    IloNum,         startTime,
                    IloNum,         startDetTime)
{
   int newIncumbent = 0;
   double dettime = getDetTime();

   if ( hasIncumbent()                                  && 
        fabs(lastIncumbent - getIncumbentObjValue())
              > 1e-5*(1.0 + fabs(getIncumbentObjValue())) ) {
      lastIncumbent = getIncumbentObjValue();
      newIncumbent = 1;
   }
     
   if ( dettime >= lastDettime + 1000.0  ||  newIncumbent ) {  

      if ( !newIncumbent )  lastDettime = dettime;
      getEnv().out() << "Time = " << getCplexTime() - startTime
                     << "  Dettime = " << dettime - startDetTime
                     << "  Best objective = " << getBestObjValue();

      if ( hasIncumbent() ) {
         getEnv().out() << "  Incumbent objective = " << getIncumbentObjValue()
                        << endl;
      }
      else {
         getEnv().out() << endl;
      }

   }
   if ( newIncumbent ) {
      IloNumArray val(vars.getEnv());
      getIncumbentValues(val, vars);
      val[0] = getIncumbentValue(vars[0]);
      getEnv().out() << "New incumbent variable values: " << endl
                     << val << endl;
      val.end();
   }
}