Changeset 181


Ignore:
Timestamp:
Oct 6, 2005 2:52:17 PM (15 years ago)
Author:
forrest
Message:

prettier messages

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcCompareActual.cpp

    r97 r181  
    218218                               int numberInfeasibilitiesAtContinuous)
    219219{
    220   if (model->getSolutionCount()==model->getNumberHeuristicSolutions())
     220  if (model->getSolutionCount()==model->getNumberHeuristicSolutions()&&
     221      model->getSolutionCount()<5&&model->getNodeCount()<500)
    221222    return; // solution was got by rounding
    222223  // set to get close to this solution
  • trunk/CbcHeuristicFPump.cpp

    r175 r181  
    156156// 5. MAIN WHILE LOOP
    157157  int numberPasses=0;
     158  bool newLineNeeded=false;
    158159  while (!finished) {
     160    returnCode=0;
    159161    if (numberPasses>=maximumPasses_) {
    160162      break;
     
    169171      // Put back correct objective
    170172      printf("\n");
     173      newLineNeeded=false;
    171174      for (i=0;i<numberColumns;i++)
    172175        solver->setObjCoeff(i,saveObjective[i]);
     
    199202         // perturbation
    200203         printf("Perturbation applied");
     204         newLineNeeded=true;
    201205         for (i=0;i<numberIntegers;i++) {
    202206             int iColumn = integerVariable[i];
     
    241245      solver->resolve();
    242246      printf("\npass %3d: obj. %10.5lf --> ", numberPasses,solver->getObjValue());
    243 
     247      newLineNeeded=true;
    244248
    245249    }
    246250  } // END WHILE
    247 
     251  if (newLineNeeded)
     252    printf(" - no solution found\n");
    248253  delete solver;
    249254  delete [] newSolution;
  • trunk/CbcHeuristicGreedy.cpp

    r175 r181  
    706706        solver2->resolve();
    707707        CbcModel model(*solver2);
     708        model.setLogLevel(1);
    708709        model.setCutoff(solutionValue);
    709710        model.setMaximumNodes(200);
     
    715716        model.setNumberBeforeTrust(1);
    716717        model.solver()->setIntParam(OsiMaxNumIterationHotStart,10);
    717         // Do complete search
     718        // Do search
     719        model_->messageHandler()->message(CBC_START_SUB,model_->messages())
     720              << "CbcHeuristicGreedy"
     721              << model.getMaximumNodes()
     722              <<CoinMessageEol;
    718723        model.branchAndBound();
     724        model_->messageHandler()->message(CBC_END_SUB,model_->messages())
     725              << "CbcHeuristicGreedy"
     726              <<CoinMessageEol;
    719727        if (model.getMinimizationObjValue()<solutionValue) {
    720728          // solution
     
    762770      memcpy(betterSolution,newSolution,numberColumns*sizeof(double));
    763771      solutionValue = newSolutionValue;
    764       printf("** Solution of %g found by greedy\n",newSolutionValue);
     772      model_->messageHandler()->message(CBC_HEURISTIC_SOLUTION,model_->messages())
     773        << newSolutionValue
     774        << "CbcHeuristicGreedy"
     775        <<CoinMessageEol;
    765776      returnCode=1;
    766777    }
  • trunk/CbcHeuristicLocal.cpp

    r175 r181  
    9494  if (!when()||(when()==1&&model_->phase()!=1))
    9595    return 0; // switched off
     96  // Don't do if it was this heuristic which found solution!
     97  if (this==model_->lastHeuristic())
     98    return 0;
    9699  OsiSolverInterface * newSolver = model_->continuousSolver()->clone();
    97100  const double * colLower = newSolver->getColLower();
     
    134137      solver2->resolve();
    135138      CbcModel model(*solver2);
     139      model.setLogLevel(1);
    136140      model.setCutoff(objectiveValue);
    137141      model.setMaximumNodes(200);
     
    143147      model.setNumberBeforeTrust(1);
    144148      model.solver()->setIntParam(OsiMaxNumIterationHotStart,10);
    145       // Do complete search
     149      // Do search
     150      model_->messageHandler()->message(CBC_START_SUB,model_->messages())
     151        << "CbcHeuristicLocal"
     152        << model.getMaximumNodes()
     153        <<CoinMessageEol;
    146154      model.branchAndBound();
     155      model_->messageHandler()->message(CBC_END_SUB,model_->messages())
     156        << "CbcHeuristicLocal"
     157        <<CoinMessageEol;
    147158      if (model.getMinimizationObjValue()<objectiveValue) {
     159        model_->messageHandler()->message(CBC_HEURISTIC_SOLUTION,model_->messages())
     160          << model.getMinimizationObjValue()
     161          << "CbcHeuristicLocal"
     162          <<CoinMessageEol;
    148163        // solution
    149164        // post process
     
    559574        returnCode=1;
    560575        solutionValue = newSolutionValue + bestChange;
    561         if (bestChange>1.0e-12)
    562           printf("Local search heuristic improved solution by %g\n",
    563                  -bestChange);
     576        if (bestChange<-1.0e-1)
     577          model_->messageHandler()->message(CBC_HEURISTIC_SOLUTION,model_->messages())
     578            << solutionValue
     579            << "CbcHeuristicLocal"
     580            <<CoinMessageEol;
    564581      } else {
    565582        // bad solution - should not happen so debug if see message
  • trunk/CbcMessage.cpp

    r152 r181  
    4545  {CBC_PRIORITY,26,1,"Setting priorities for objects %d to %d inclusive (out of %d)"},
    4646  {CBC_WARNING_STRONG,3008,1,"Strong branching is fixing too many variables, too expensively!"},
     47  {CBC_START_SUB,28,1,"Starting sub-tree for %s - maximum nodes %d"},
     48  {CBC_END_SUB,29,1,"Ending sub-tree for %s"},
     49  {CBC_HEURISTIC_SOLUTION,30,1,"solution of %g found by %s"},
    4750  {CBC_DUMMY_END,999999,0,""}
    4851};
  • trunk/CbcModel.cpp

    r171 r181  
    11841184              { estValue = CoinMin(heurValue,estValue) ;
    11851185                heurValue = saveValue ; } }
    1186             if (found >= 0)
    1187             { setBestSolution(CBC_ROUNDING,heurValue,newSolution) ; }
     1186            if (found >= 0) {
     1187              setBestSolution(CBC_ROUNDING,heurValue,newSolution) ;
     1188              lastHeuristic_ = heuristic_[found];
     1189            }
    11881190            delete [] newSolution ;
    11891191            newNode->setGuessedObjectiveValue(estValue) ;
     
    12141216            setBestSolution(CBC_SOLUTION,objectiveValue,
    12151217                            solver_->getColSolution()) ;
     1218            lastHeuristic_ = NULL;
    12161219            incrementUsed(solver_->getColSolution());
    12171220            assert(nodeInfo->numberPointingToThis() <= 2) ;
     
    16321635  numberHeuristics_(0),
    16331636  heuristic_(NULL),
     1637  lastHeuristic_(NULL),
    16341638  numberObjects_(0),
    16351639  object_(NULL),
     
    17171721  numberHeuristics_(0),
    17181722  heuristic_(NULL),
     1723  lastHeuristic_(NULL),
    17191724  numberObjects_(0),
    17201725  object_(NULL),
     
    19381943    heuristic_=NULL;
    19391944  }
     1945  lastHeuristic_ = NULL;
    19401946  numberObjects_=rhs.numberObjects_;
    19411947  if (numberObjects_) {
     
    21402146    delete [] virginGenerator_;
    21412147    delete [] heuristic_;
     2148    lastHeuristic_ = NULL;
    21422149    numberCutGenerators_ = rhs.numberCutGenerators_;
    21432150    if (numberCutGenerators_) {
     
    21612168      heuristic_=NULL;
    21622169    }
     2170    lastHeuristic_ = NULL;
    21632171    for (i=0;i<numberObjects_;i++)
    21642172      delete object_[i];
     
    22722280  delete [] heuristic_;
    22732281  heuristic_=NULL;
     2282  lastHeuristic_ = NULL;
    22742283  delete nodeCompare_;
    22752284  nodeCompare_=NULL;
     
    30983107  the vector.
    30993108*/
    3100     if (found >= 0)
    3101     {
     3109    if (found >= 0) {
    31023110      phase_=4;
    31033111      incrementUsed(newSolution);
    3104       setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ; }
     3112      setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
     3113      lastHeuristic_ = heuristic_[found];
     3114    }
    31053115    delete [] newSolution ;
    31063116
     
    33833393      incrementUsed(newSolution);
    33843394      setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
     3395      lastHeuristic_ = heuristic_[found];
    33853396    }
    33863397    delete [] newSolution ;
     
    52985309          setBestSolution(CBC_ROUNDING,heuristicValue,
    52995310                          newSolution);
     5311          lastHeuristic_ = heuristic_[found];
    53005312          // update cutoff
    53015313          cutoff = getCutoff();
  • trunk/CbcNode.cpp

    r167 r181  
    13691369                                     newObjectiveValue,
    13701370                                     solver->getColSolution()) ;
     1371              model->setLastHeuristic(NULL);
    13711372              model->incrementUsed(solver->getColSolution());
    13721373              if (newObjectiveValue >= model->getCutoff())      //  *new* cutoff
     
    14541455                                     newObjectiveValue,
    14551456                                     solver->getColSolution()) ;
     1457              model->setLastHeuristic(NULL);
    14561458              model->incrementUsed(solver->getColSolution());
    14571459              if (newObjectiveValue >= model->getCutoff())      //  *new* cutoff
     
    22672269                                       newObjectiveValue,
    22682270                                       solver->getColSolution()) ;
     2271                model->setLastHeuristic(NULL);
    22692272                model->incrementUsed(solver->getColSolution());
    22702273                cutoff =model->getCutoff();
     
    23272330                                       newObjectiveValue,
    23282331                                       solver->getColSolution()) ;
     2332                model->setLastHeuristic(NULL);
    23292333                model->incrementUsed(solver->getColSolution());
    23302334                cutoff =model->getCutoff();
  • trunk/include/CbcMessage.hpp

    r143 r181  
    5050  CBC_PRIORITY,
    5151  CBC_WARNING_STRONG,
     52  CBC_START_SUB,
     53  CBC_END_SUB,
     54  CBC_HEURISTIC_SOLUTION,
    5255  CBC_DUMMY_END
    5356};
  • trunk/include/CbcModel.hpp

    r165 r181  
    11551155  inline int numberHeuristics() const
    11561156  { return numberHeuristics_;};
     1157  /// Pointer to heuristic solver which found last solution (or NULL)
     1158  inline CbcHeuristic * lastHeuristic() const
     1159  { return lastHeuristic_;};
     1160  /// set last heuristic which found a solution
     1161  inline void setLastHeuristic(CbcHeuristic * last)
     1162  { lastHeuristic_=last;};
    11571163
    11581164  /** Pass in branching priorities.
     
    15161522  /// Number of heuristics
    15171523  int numberHeuristics_;
    1518   // Heuristic solvers
     1524  /// Heuristic solvers
    15191525  CbcHeuristic ** heuristic_;
     1526  /// Pointer to heuristic solver which found last solution (or NULL)
     1527  CbcHeuristic * lastHeuristic_;
    15201528
    15211529  /// Total number of objects
Note: See TracChangeset for help on using the changeset viewer.