Changeset 1158


Ignore:
Timestamp:
Apr 24, 2009 7:11:59 AM (10 years ago)
Author:
forrest
Message:

out mini tree and stuff for parallel heuristics and fpump

Location:
trunk/Cbc/src
Files:
7 edited

Legend:

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

    r1151 r1158  
    477477CbcHeuristic::exitNow(double bestObjective) const
    478478{
    479   if ((switches_&1)==0)
     479  if ((switches_&2048)!=0) {
     480    // exit may be forced - but unset for next time
     481    switches_ &= ~2048;
     482    if ((switches_&1024)!=0)
     483      return true;
     484  } else if ((switches_&1)==0) {
    480485    return false;
     486  }
    481487  // See if can stop on gap
    482488  OsiSolverInterface * solver = model_->solver();
  • trunk/Cbc/src/CbcHeuristic.hpp

    r1127 r1158  
    138138      1 bit - stop once allowable gap on objective reached
    139139      2 bit - always do given number of passes
    140       for other possibilities see switches_
     140      4 bit - weaken cutoff by 5% every 50 passes?
     141      8 bit - if has cutoff and suminf bobbling for 20 passes then
     142              first try halving distance to best possible then
     143              try keep halving distance to known cutoff
     144      1024 bit - stop all heuristics on max time
    141145  */
    142146  inline void setSwitches(int value)
     
    145149      1 bit - stop once allowable gap on objective reached
    146150      2 bit - always do given number of passes
    147       for other possibilities see switches_
     151      4 bit - weaken cutoff by 5% every 50 passes?
     152      8 bit - if has cutoff and suminf bobbling for 20 passes then
     153              first try halving distance to best possible then
     154              try keep halving distance to known cutoff
     155      1024 bit - stop all heuristics on max time
    148156  */
    149157  inline int switches() const
     
    246254      8 bit - if has cutoff and suminf bobbling for 20 passes then
    247255              first try halving distance to best possible then
    248               try keep halving distance to known cutoff
    249   */
    250   int switches_;
     256              try keep halving distance to known cutoff
     257      1024 bit - stop all heuristics on max time
     258  */
     259  mutable int switches_;
    251260  /** Upto this depth we call the tree shallow and the heuristic can be called
    252261      multiple times. That is, the test whether the current node is far from
  • trunk/Cbc/src/CbcHeuristicFPump.cpp

    r1156 r1158  
    201201                         double * betterSolution)
    202202{
     203  startTime_=CoinCpuTime();
    203204  numCouldRun_++;
    204205  double incomingObjective = solutionValue;
     
    607608        exitAll=true;
    608609      }
    609       if (maximumTime_>0.0&&CoinCpuTime()>=startTime_+maximumTime_)
     610      if (maximumTime_>0.0&&CoinCpuTime()>=startTime_+maximumTime_) {
    610611        exitAll=true;
     612        // force exit
     613        switches_ |= 2048;
     614      }
    611615      if (exitAll||exitThis)
    612616        break;
     
    972976          if (dualPass&&numberChanged>2) {
    973977            solver->setHintParam(OsiDoDualInResolve,true); // dual may be better
    974             if (dualPass==1&&2*numberChanged<numberColumns) {
     978            if (dualPass==1&&2*numberChanged<numberColumns&&
     979                (numberChanged<5000||6*numberChanged<numberColumns)) {
    975980              // but we need to make infeasible
    976981              CoinWarmStartBasis * basis =
     
    19391944  const double * rowUpper = solver->getRowUpper();
    19401945  int numberRows = solver->getNumRows();
    1941   if ((iter&1)!=0) {
     1946  if (false&&(iter&1)!=0) {
    19421947    // Do set covering variables
    19431948    const CoinPackedMatrix * matrixByRow = solver->getMatrixByRow();
  • trunk/Cbc/src/CbcHeuristicRINS.cpp

    r1156 r1158  
    177177 
    178178    const double * currentSolution = solver->getColSolution();
    179     OsiSolverInterface * newSolver = model_->continuousSolver() ?
    180       model_->continuousSolver()->clone() : solver->clone();
     179    OsiSolverInterface * newSolver = model_->continuousSolver()->clone();
    181180    //const double * colLower = newSolver->getColLower();
    182181    //const double * colUpper = newSolver->getColUpper();
     
    309308 
    310309  const double * currentSolution = solver->getColSolution();
    311   OsiSolverInterface * newSolver = model_->continuousSolver() ?
    312     model_->continuousSolver()->clone() : solver->clone();
     310  OsiSolverInterface * newSolver = model_->continuousSolver()->clone();
    313311  const double * colLower = newSolver->getColLower();
    314312  const double * colUpper = newSolver->getColUpper();
     
    562560    while(status) {
    563561      status=0;
    564       OsiSolverInterface * newSolver = model_->continuousSolver() ?
    565         model_->continuousSolver()->clone() : solver->clone();
     562      OsiSolverInterface * newSolver = model_->continuousSolver()->clone();
    566563      const double * colLower = solver->getColLower();
    567564      const double * colUpper = solver->getColUpper();
  • trunk/Cbc/src/CbcModel.cpp

    r1156 r1158  
    41564156  numberOldActiveCuts_(0),
    41574157  numberNewCuts_(0),
    4158   sizeMiniTree_(0),
    41594158  searchStrategy_(-1),
    41604159  numberStrongIterations_(0),
     
    43174316  numberOldActiveCuts_(0),
    43184317  numberNewCuts_(0),
    4319   sizeMiniTree_(0),
    43204318  searchStrategy_(-1),
    43214319  numberStrongIterations_(0),
     
    45564554  numberOldActiveCuts_(rhs.numberOldActiveCuts_),
    45574555  numberNewCuts_(rhs.numberNewCuts_),
    4558   sizeMiniTree_(rhs.sizeMiniTree_),
    45594556  searchStrategy_(rhs.searchStrategy_),
    45604557  numberStrongIterations_(rhs.numberStrongIterations_),
     
    49174914    numberThreads_ = rhs.numberThreads_;
    49184915    threadMode_ = rhs.threadMode_;
    4919     sizeMiniTree_ = rhs.sizeMiniTree_;
    49204916    searchStrategy_ = rhs.searchStrategy_;
    49214917    numberStrongIterations_ = rhs.numberStrongIterations_;
     
    1296512961          parameters[i-iChunk].solutionValue=heuristicValue;
    1296612962          CbcModel * newModel = new CbcModel(*this);
    12967           //delete newModel->solver_;
    12968           //newModel->solver_ = solver_->clone();
     12963          assert (!newModel->continuousSolver_);
     12964          if (continuousSolver_)
     12965            newModel->continuousSolver_ = continuousSolver_->clone();
     12966          else
     12967            newModel->continuousSolver_ = solver_->clone();
    1296912968          parameters[i-iChunk].model = newModel;
    1297012969          parameters[i-iChunk].solution = new double [numberColumns];;
     
    1298712986        }
    1298812987        double cutoff=heuristicValue;
     12988        bool exitNow=false;
    1298912989        for (int i=0;i<chunk;i++) {
    1299012990          if (parameters[i].model) {
     
    1300613006                numberHeuristicSolutions_++;
    1300713007                found = i+iChunk ;
    13008                 if (heuristic_[i+iChunk]->exitNow(bestObjective_))
    13009                   break;
    1301013008              }
    1301113009            }
     13010            if (heuristic_[i+iChunk]->exitNow(bestObjective_)||
     13011                (parameters[i].model->heuristic(0)->switches()&2048)!=0)
     13012              exitNow=true;
    1301213013            delete parameters[i].solution;
    1301313014            delete parameters[i].model;
     
    1301613017        delete [] threadId;
    1301713018        delete [] parameters;
     13019        if (exitNow)
     13020          break;
    1301813021      }
    1301913022    } else {
  • trunk/Cbc/src/CbcModel.hpp

    r1156 r1158  
    700700  */
    701701  bool doCutsNow(int allowForTopOfTree) const;
    702   /** Set size of mini - tree.  If > 1 then does total enumeration of
    703       tree given by this best variables to branch on
    704   */
    705   inline void setSizeMiniTree(int value)
    706   { sizeMiniTree_=value;}
    707   inline int sizeMiniTree() const
    708   { return sizeMiniTree_;}
    709702
    710703  /** Set the number of branches before pseudo costs believed
     
    22332226  /// Number of new cuts
    22342227  int numberNewCuts_;
    2235   /// Size of mini - tree
    2236   int sizeMiniTree_;
    22372228  /// Strategy worked out - mainly at root node
    22382229  int searchStrategy_;
  • trunk/Cbc/src/CbcNode.cpp

    r1148 r1158  
    25102510  if (!decision)
    25112511    decision = new CbcBranchDynamicDecision();
    2512   int numberMini=0;
    25132512  int xPen=0;
    25142513  int xMark=0;
     
    36903689        }
    36913690      }
    3692       // See if we want mini tree
    3693       bool wantMiniTree=false;
    3694       if (model->sizeMiniTree()&&depth_>7&&saveStateOfSearch>0)
    3695         wantMiniTree=true;
    3696       numberMini=0;
    3697       //if (skipAll&&numberTest==0&&doQuickly)
    3698       //numberToDo = 1; // trust previous stuff
    36993691      bool couldChooseFirst = false ; //(skipAll&&numberTest==0&&doQuickly);
    37003692      //skipAll=false;
     
    41714163                <<CoinMessageEol;
    41724164            }
    4173             //if (!stateOfSearch)
    4174             //choice.numIntInfeasDown=99999; // temp fudge
    4175             if (wantMiniTree)
    4176               decision->setBestCriterion(-1.0);
    41774165            double bestCriterion = -1.0;
    41784166            //double gap = saveUpper[iColumn]-saveLower[iColumn];
     
    41934181                                                     choice.numIntInfeasDown );
    41944182            }
    4195             if (wantMiniTree) {
    4196               double criterion = decision->getBestCriterion();
    4197               sort[numberMini]=-criterion;
    4198               whichObject[numberMini++]=whichObject[iDo];
    4199               assert (betterWay);
    4200               if (criterion>bestCriterion)
    4201                 bestCriterion=criterion;
    4202               else
    4203                 betterWay=0;
    4204             }
    42054183            if (iDo>=changeStrategy) {
    42064184              // make less likely
     
    44864464            if (feasible) {
    44874465              anyAction=0;
    4488               numberMini=0;
    44894466              // See if candidate still possible
    44904467              if (branch_) {
     
    46314608  guessedObjectiveValue_ = objectiveValue_+estimatedDegradation;
    46324609 
    4633   // Get collection of branches if mini tree wanted
    4634   if (anyAction==0&&numberMini&&numberMini>1) {
    4635     // Sort
    4636     CoinSort_2(sort,sort+numberMini,whichObject);
    4637     delete branch_;
    4638     branch_=NULL;
    4639     numberMini = CoinMin(numberMini,model->sizeMiniTree());
    4640     anyAction=numberMini;
    4641     branches = new OsiSolverBranch[numberMini];
    4642     for (int iDo=0;iDo<numberMini;iDo++) {
    4643       int iObject = whichObject[iDo];
    4644       OsiObject * object = model->modifiableObject(iObject);
    4645       CbcSimpleInteger * obj =
    4646         dynamic_cast <CbcSimpleInteger *>(object) ;
    4647       OsiSolverBranch * oneBranch;
    4648       if (obj) {
    4649         oneBranch = obj->solverBranch(solver,&usefulInfo);
    4650       } else {
    4651         CbcObject * obj =
    4652           dynamic_cast <CbcObject *>(object) ;
    4653         assert (obj);
    4654         oneBranch = obj->solverBranch();
    4655       }
    4656       branches[iDo]=*oneBranch;
    4657       delete oneBranch;
    4658     }
    4659   }
    46604610/*
    46614611  Cleanup, then we're finished
Note: See TracChangeset for help on using the changeset viewer.