Ignore:
Timestamp:
Jul 3, 2006 7:07:32 AM (14 years ago)
Author:
forrest
Message:

for cut generators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcModel.cpp

    r391 r395  
    619619*/
    620620  synchronizeModel() ;
    621   assert (!solverCharacteristics_);
    622   OsiBabSolver * solverCharacteristics = dynamic_cast<OsiBabSolver *> (solver_->getAuxiliaryInfo());
    623   if (solverCharacteristics) {
    624     solverCharacteristics_ = solverCharacteristics;
    625   } else {
    626     // replace in solver
    627     OsiBabSolver defaultC;
    628     solver_->setAuxiliaryInfo(&defaultC);
    629     solverCharacteristics_ = dynamic_cast<OsiBabSolver *> (solver_->getAuxiliaryInfo());
     621  if (!solverCharacteristics_) {
     622    OsiBabSolver * solverCharacteristics = dynamic_cast<OsiBabSolver *> (solver_->getAuxiliaryInfo());
     623    if (solverCharacteristics) {
     624      solverCharacteristics_ = solverCharacteristics;
     625    } else {
     626      // replace in solver
     627      OsiBabSolver defaultC;
     628      solver_->setAuxiliaryInfo(&defaultC);
     629      solverCharacteristics_ = dynamic_cast<OsiBabSolver *> (solver_->getAuxiliaryInfo());
     630    }
    630631  }
    631632  solverCharacteristics_->setSolver(solver_);
     
    641642  bool feasible;
    642643  // If NLP then we assume already solved outside branchAndbound
    643   if (!solverCharacteristics_->solverType()) {
     644  if (!solverCharacteristics_->solverType()||solverCharacteristics_->solverType()==4) {
    644645    feasible=resolve(NULL,0) != 0 ;
    645646  } else {
     
    831832    // replace solverType
    832833    if(solverCharacteristics_->tryCuts())  {
     834
    833835      if (numberUnsatisfied)   {
    834836        feasible = solveWithCuts(cuts,maximumCutPassesAtRoot_,
    835837                                 NULL);
    836       } else if (solverCharacteristics_->solutionAddsCuts()) {
     838      } else if (solverCharacteristics_->solutionAddsCuts()||
     839                 solverCharacteristics_->alwaysTryCutsAtRootNode()) {
    837840        // may generate cuts and turn the solution
    838841        //to an infeasible one
     
    18961899  public methods.
    18971900*/
    1898   if (bestSolution_&&solverCharacteristics_->solverType()<2)
     1901  if (bestSolution_&&(solverCharacteristics_->solverType()<2||solverCharacteristics_->solverType()==4))
    18991902  { setCutoff(1.0e50) ; // As best solution should be worse than cutoff
    19001903    phase_=5;
     
    36783681  currentPassNumber_ = 0 ;
    36793682  double primalTolerance = 1.0e-7 ;
     3683  // We may need to keep going on
     3684  bool keepGoing=false;
    36803685/*
    36813686  Begin cut generation loop. Cuts generated during each iteration are
     
    36943699  { currentPassNumber_++ ;
    36953700    numberTries-- ;
     3701    if (numberTries<0&&keepGoing) {
     3702      // switch off all normal ones
     3703      for (int i = 0;i<numberCutGenerators_;i++) {
     3704        if (!generator_[i]->mustCallAgain())
     3705          generator_[i]->setSwitchedOff(true);
     3706      }
     3707    }
     3708    keepGoing=false;
    36963709    OsiCuts theseCuts ;
    36973710/*
     
    37883801        if (generator_[i]->needsOptimalBasis()&&!solver_->basisIsAvailable())
    37893802          generate=false;
     3803        if (generator_[i]->switchedOff())
     3804          generate=false;;
    37903805        if (generate) {
    37913806          bool mustResolve =
    37923807            generator_[i]->generateCuts(theseCuts,fullScan,node) ;
     3808          if(numberRowCutsBefore < theseCuts.sizeRowCuts() &&
     3809             generator_[i]->mustCallAgain())
     3810            keepGoing=true; // say must go round
    37933811#ifdef CBC_DEBUG
    37943812          {
     
    41784196        lastNumberCuts = numberNewCuts_ ;
    41794197        if (direction*solver_->getObjValue() < lastObjective+minimumDrop &&
    4180             currentPassNumber_ >= 3)
     4198            currentPassNumber_ >= 3 && !keepGoing)
    41814199          { numberTries = 0 ; }
    41824200        if (numberRowCuts+numberColumnCuts == 0 || cutIterations == 0)
     
    42044222      numberTries = 0 ;
    42054223    }
    4206   } while (numberTries>0) ;
     4224  } while (numberTries>0||keepGoing) ;
     4225  {
     4226    // switch on
     4227    for (int i = 0;i<numberCutGenerators_;i++)
     4228      generator_[i]->setSwitchedOff(false);
     4229  }
    42074230  //check feasibility.
    42084231  //If solution seems to be integer feasible calling setBestSolution
     
    76337656  return CoinCpuTime()-getDblParam(CbcStartSeconds);
    76347657}
     7658/*
     7659   For advanced applications you may wish to modify the behavior of Cbc
     7660   e.g. if the solver is a NLP solver then you may not have an exact
     7661   optimum solution at each step.  Information could be built into
     7662   OsiSolverInterface but this is an alternative so that that interface
     7663   does not have to be changed.  If something similar is useful to
     7664   enough solvers then it could be migrated.
     7665   You can also pass in by using solver->setAuxiliaryInfo.
     7666   You should do that if solver is odd - if solver is normal simplex
     7667   then use this
     7668*/
     7669void
     7670CbcModel::passInSolverCharacteristics(OsiBabSolver * solverCharacteristics)
     7671{
     7672  solverCharacteristics_ = solverCharacteristics;
     7673}
    76357674// Create C++ lines to get to current state
    76367675void
Note: See TracChangeset for help on using the changeset viewer.