Changeset 952


Ignore:
Timestamp:
May 26, 2008 6:23:18 AM (11 years ago)
Author:
forrest
Message:

for stored cuts

Location:
trunk/Cbc/src
Files:
3 edited

Legend:

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

    r838 r952  
    107107  ownerCut_=whichOne;
    108108}
     109// Returns true if can drop cut if slack basic
     110bool
     111CbcCountRowCut::canDropCut(const OsiSolverInterface * solver, int iRow) const
     112{
     113  // keep if COIN_DBL_MAX otherwise keep if slack zero
     114  if (effectiveness()<1.0e20) {
     115    return true;
     116  } else if (effectiveness()!=COIN_DBL_MAX) {
     117    const double * rowActivity = solver->getRowActivity();
     118    const double * rowLower = solver->getRowLower();
     119    const double * rowUpper = solver->getRowUpper();
     120    double tolerance;
     121    solver->getDblParam(OsiPrimalTolerance,tolerance) ;
     122    double value = rowActivity[iRow];
     123    if (value<rowLower[iRow]+tolerance||
     124        value>rowUpper[iRow]-tolerance)
     125      return false;
     126    else
     127      return true;
     128  } else {
     129    return false;
     130  }
     131}
    109132
  • trunk/Cbc/src/CbcCountRowCut.hpp

    r838 r952  
    7676
    7777  /// Which generator for cuts - as user order
    78   int whichCutGenerator() const
     78  inline int whichCutGenerator() const
    7979  { return whichCutGenerator_;}
     80 
     81  /// Returns true if can drop cut if slack basic
     82  bool canDropCut(const OsiSolverInterface * solver, int row) const;
    8083
    8184#ifdef CHECK_CUT_COUNTS
  • trunk/Cbc/src/CbcModel.cpp

    r940 r952  
    51935193  }
    51945194  if (!lastws->fullBasis()) {
     5195#ifdef COIN_DEVELOP
    51955196    printf("******* bad basis\n");
     5197#endif
    51965198    int numberRows = lastws->getNumArtificial();
    51975199    int i;
     
    53895391        if (addedCuts_[i] &&
    53905392            (status != CoinWarmStartBasis::basic ||
    5391              addedCuts_[i]->effectiveness()==COIN_DBL_MAX)) {
     5393             (addedCuts_[i]->effectiveness()>1.0e10&&
     5394              !addedCuts_[i]->canDropCut(solver_,i+numberRowsAtContinuous_)))) {
    53925395#         ifdef CHECK_CUT_COUNTS
    53935396          printf("Using cut %d %x as row %d\n",i,addedCuts_[i],
     
    73357338        // always leave if from nextRowCut_
    73367339        if (status == CoinWarmStartBasis::basic&&
    7337             addedCuts_[oldCutIndex]->effectiveness()!=COIN_DBL_MAX)
     7340            (addedCuts_[oldCutIndex]->effectiveness()<=1.0e10||
     7341             addedCuts_[oldCutIndex]->canDropCut(solver_,i+firstOldCut)))
    73387342          { solverCutIndices[numberOldToDelete++] = i+firstOldCut ;
    73397343          if (saveCuts) {
     
    1160411608    double * saveUpper = CoinCopyOfArray(solver_->getColUpper(),numberColumns);
    1160511609    // Fix integers
     11610    int numberAway=0;
    1160611611    for (int i=0;i<numberColumns;i++) {
    1160711612      if (solver_->isInteger(i)) {
    1160811613        double value = solution[i];
    1160911614        double intValue = floor(value+0.5);
    11610         assert (fabs(value-intValue)<1.0e-4);
     11615        if (fabs(value-intValue)>1.0e-4)
     11616          numberAway++;
    1161111617        solver_->setColLower(i,intValue);
    1161211618        solver_->setColUpper(i,intValue);
     
    1161811624    solver_->initialSolve();
    1161911625    char printBuffer[200];
     11626    if (numberAway) {
     11627      sprintf(printBuffer,"Warning %d integer variables were more than 1.0e-4 away from integer",numberAway);
     11628      messageHandler()->message(CBC_FPUMP1,messages())
     11629        << printBuffer << CoinMessageEol ;
     11630    }
    1162011631    bool looksGood = solver_->isProvenOptimal();
    1162111632    if (looksGood) {
     
    1165711668      messageHandler()->message(CBC_FPUMP1,messages())
    1165811669        << printBuffer << CoinMessageEol ;
     11670      // may be able to change cutoff now
     11671      double cutoff = getCutoff();
     11672      double increment = getDblParam(CbcModel::CbcCutoffIncrement) ;
     11673      if (cutoff > objectiveValue-increment) {
     11674        cutoff = objectiveValue-increment ;
     11675        setCutoff(cutoff) ;
     11676      }
    1165911677    }
    1166011678  }
Note: See TracChangeset for help on using the changeset viewer.