Changeset 1957 for trunk/Cbc/src


Ignore:
Timestamp:
Aug 27, 2013 11:19:55 AM (6 years ago)
Author:
forrest
Message:

minor fixes and take out printout

Location:
trunk/Cbc/src
Files:
5 edited

Legend:

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

    r1956 r1957  
    33// Corporation and others.  All Rights Reserved.
    44// This code is licensed under the terms of the Eclipse Public License (EPL).
    5 
    6 // edwin 12/5/09 carved out of CbcHeuristicRINS
    75
    86#if defined(_MSC_VER)
     
    9997  fullDWEverySoOften_=0;
    10098  numberPasses_=0;
     99  numberBadPasses_=COIN_INT_MAX;
    101100  maximumDW_=0;
    102101  numberDW_=0;
     
    124123  fullDWEverySoOften_ = rhs.fullDWEverySoOften_;
    125124  numberPasses_ = rhs.numberPasses_;
     125  numberBadPasses_= rhs.numberBadPasses_;
    126126  howOften_ = rhs.howOften_;
    127127  decayFactor_ = rhs.decayFactor_;
     
    338338  sprintf(dwPrint,"Before PASSes objective is %g",
    339339          bestObjective_);
     340  lastObjective_ = bestObjective_;
    340341  model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
    341342    << dwPrint
     
    473474    << dwPrint
    474475    << CoinMessageEol;
     476  int lastGoodPass=0;
    475477  for (pass_=0;pass_<numberPasses_;pass_++) {
    476478    double endTime2 = CoinCpuTime();
     
    522524    startTime2 = CoinCpuTime();
    523525    startTime2Elapsed = CoinGetTimeOfDay();
     526    if (pass_-lastGoodPass>numberBadPasses_) {
     527      sprintf(dwPrint,"Exiting on lack of progress");
     528      model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
     529        << dwPrint
     530        << CoinMessageEol;
     531      break;
     532    }
    524533    if (model_->getNodeCount()>=model_->getMaximumNodes()||
    525534        model_->maximumSecondsReached()) {
     
    562571      (*(functionPointer_))(this,NULL,4);
    563572      solveState_=0;
    564       //lastObjective=bestObjective_;
     573      //lastObjective_=bestObjective_;
    565574      if (phase_) {
    566575        //nNeededBase_ += nNeededBase_/50;
     
    587596    }
    588597    if (goodSolution) {
     598      lastGoodPass=pass_;
    589599      int lastNumberDW=numberDW_;
    590600      solver->setColSolution(bestSolution_);
     
    597607      solver->resolve();
    598608      solver->setHintParam(OsiDoReducePrint, true, OsiHintDo, 0) ;
    599       if (solver->getObjValue()<bestObjective_-1.0e-5) {
     609      if (solver->getObjValue()<lastObjective_-1.0e-5) {
    600610        memcpy(bestSolution_,solver->getColSolution(),
    601611               numberColumns*sizeof(double));
     
    665675          OsiClpSolverInterface solverX(tempModel,true);
    666676          CbcModel modelX(solverX);
    667           modelX.setLogLevel(0);
     677          modelX.setLogLevel(1);
     678          modelX.setMoreSpecialOptions2(57);
     679          // need to stop after solutions and nodes
     680          //modelX.setMaximumNodes(nNodes_);
     681          modelX.setMaximumSolutions(1);
    668682          modelX.branchAndBound();
    669683          const double * bestSolutionX = modelX.bestSolution();
     
    678692        }
    679693        addDW(bestSolution2,numberUsed,whichBlock);
     694        if (!pass_&&false) {
     695          // see if gives a solution
     696          for ( int i=0 ; i<numberColumns ; ++i ) {
     697            if (solver_->isInteger(i)) {
     698              double value = floor(bestSolution2[i]+0.5);
     699              columnLower[i] = value;
     700              columnUpper[i] = value;
     701            } else {
     702              columnLower[i] = saveLower_[i];
     703              columnUpper[i] = saveUpper_[i];
     704            }
     705          }
     706          solver_->resolve();
     707          if (solver_->isProvenOptimal()) {
     708            printf ("DW1 sol %g\n",solver->getObjValue());
     709          }
     710        }
    680711        // now try purer DW
    681712        bool takeHint;
     
    706737            int iColumn=columnsInBlock_[i];
    707738            columnLowerX[jColumn]=CoinMax(saveLower_[iColumn],-1.0e12);
    708             columnUpperX[jColumn]=CoinMin(saveUpper_[iColumn],1.0e-12);
     739            columnUpperX[jColumn]=CoinMin(saveUpper_[iColumn],1.0e12);
    709740            if (solver->isInteger(iColumn))
    710741              tempModel->setInteger(jColumn);
     
    725756          double cObj=solverX.getObjValue();
    726757          CbcModel modelX(solverX);
    727           modelX.setLogLevel(0);
     758          modelX.setLogLevel(1);
     759          modelX.setMoreSpecialOptions2(57);
     760          modelX.setMaximumSolutions(1);
    728761          modelX.branchAndBound();
    729762          sprintf(dwPrint,"Block %d contobj %g intobj %g convdual %g",
     
    742775        }
    743776        addDW(bestSolution2,numberUsed,whichBlock);
     777        if (!pass_&&false) {
     778          // see if gives a solution
     779          for ( int i=0 ; i<numberColumns ; ++i ) {
     780            if (solver_->isInteger(i)) {
     781              double value = floor(bestSolution2[i]+0.5);
     782              columnLower[i] = value;
     783              columnUpper[i] = value;
     784            } else {
     785              columnLower[i] = saveLower_[i];
     786              columnUpper[i] = saveUpper_[i];
     787            }
     788          }
     789          solver_->resolve();
     790          if (solver_->isProvenOptimal()) {
     791            printf ("DW sol %g\n",solver->getObjValue());
     792          }
     793        }
    744794        delete [] bestSolution2;
    745795      }
     
    10041054        }
    10051055      }
    1006       abort();
     1056      //abort();
     1057      sprintf(dwPrint,"**** Continuous below best - bad solution passed in?!");
     1058      model_->messageHandler()->message(CBC_FPUMP1, model_->messages())
     1059        << dwPrint
     1060        << CoinMessageEol;
     1061      // give up
     1062      break;
    10071063    }
    10081064    const double * tempSol = solver->getColSolution();
  • trunk/Cbc/src/CbcHeuristicDW.hpp

    r1955 r1957  
    108108    inline void setNumberPasses(int value)
    109109    { numberPasses_ = value;}
     110    /// Set number of passes without better solution
     111    inline void setNumberBadPasses(int value)
     112    { numberBadPasses_ = value;}
    110113    /// Set number free integers needed (Base value)
    111114    inline void setNumberNeeded(int value)
     
    298301    /// Base number of nodes needed
    299302    int nNodes_;
     303    /// Number of passes without better solution
     304    int numberBadPasses_;
    300305    // 0 - fine, 1 can't be better, 2 max node
    301306    int solveState_;
  • trunk/Cbc/src/CbcMipStartIO.cpp

    r1943 r1957  
    171171#endif
    172172   lp->initialSolve();
     173   //lp->writeMps("fixed","mps");
    173174   if (!lp->isProvenOptimal())
    174175   {
     
    259260      model->messageHandler()->message(CBC_GENERAL, model->messages())
    260261        << printLine << CoinMessageEol;
     262#if 0
    261263      {
    262264        int numberColumns=lp->getNumCols();
     
    349351          printf("Cfeasible (%g) - obj %g\n", largestInfeasibility,objValue);
    350352      }
     353#endif
    351354      for ( int i=0 ; (i<lp->getNumCols()) ; ++i )
    352355      {
     
    359362#else
    360363         if (lp->isInteger(i)) {
    361            if (fabs(sol[i] - floor( sol[i]+0.5 ))>1.0e-8)
    362              printf("bad sol for %d - %.12g\n",i,sol[i]);
     364           //if (fabs(sol[i] - floor( sol[i]+0.5 ))>1.0e-8)
     365           //printf("bad sol for %d - %.12g\n",i,sol[i]);
    363366           sol[i] = floor( sol[i]+0.5 );
    364367         }
    365368#endif
    366369      }
     370#if 0
    367371      {
    368372        int numberColumns=lp->getNumCols();
     
    452456          printf("Dfeasible (%g) - obj %g\n", largestInfeasibility,objValue);
    453457      }
     458#endif
    454459#if JUST_FIX_INTEGER
    455460      const double * oldLower = model->solver()->getColLower();
  • trunk/Cbc/src/CbcNode.hpp

    r1573 r1957  
    308308        else state_ &= ~2;
    309309    }
     310    /// Get state (really for debug)
     311    inline int getState() const
     312    { return state_;}
     313    /// Set state (really for debug)
     314    inline void setState(int value)
     315    { state_ = value;}
    310316    /// Print
    311317    void print() const;
  • trunk/Cbc/src/CbcSolverHeuristics.cpp

    r1956 r1957  
    16061606        heuristic13.setHeuristicName("Dantzig-Wolfe");
    16071607        heuristic13.setNumberPasses(100);
     1608        heuristic13.setNumberBadPasses(10);
    16081609        int numberIntegers=0;
    16091610        const OsiSolverInterface * solver = model->solver();
Note: See TracChangeset for help on using the changeset viewer.