Changeset 1224


Ignore:
Timestamp:
Sep 10, 2009 12:23:09 PM (10 years ago)
Author:
forrest
Message:

changes to heuristics

Location:
trunk/Cbc/src
Files:
15 edited

Legend:

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

    r1211 r1224  
    14011401  olb = model_->solver()->getColLower()[iColumn] ;
    14021402  oub = model_->solver()->getColUpper()[iColumn] ;
     1403  //#define TIGHTEN_BOUNDS
     1404#ifndef TIGHTEN_BOUNDS
    14031405#ifdef COIN_DEVELOP
    14041406  if (olb!=down_[0]||oub!=up_[1]) {
     
    14111413  }
    14121414#endif
     1415#endif
    14131416  if (way_<0) {
    14141417#ifdef CBC_DEBUG
     
    14191422           iColumn,olb,oub,down_[0],down_[1]) ; }
    14201423#endif
     1424#ifndef TIGHTEN_BOUNDS
    14211425    model_->solver()->setColLower(iColumn,down_[0]);
     1426#else
     1427    model_->solver()->setColLower(iColumn,CoinMax(down_[0],olb));
     1428#endif
    14221429    model_->solver()->setColUpper(iColumn,down_[1]);
    14231430    //#define CBC_PRINT2
     
    14641471#endif
    14651472    model_->solver()->setColLower(iColumn,up_[0]);
     1473#ifndef TIGHTEN_BOUNDS
    14661474    model_->solver()->setColUpper(iColumn,up_[1]);
     1475#else
     1476    model_->solver()->setColUpper(iColumn,CoinMin(up_[1],oub));
     1477#endif
    14671478#ifdef CBC_PRINT2
    14681479    printf("%d branching up has bounds %g %g",iColumn,up_[0],up_[1]);
  • trunk/Cbc/src/CbcBranchDynamic.cpp

    r1212 r1224  
    114114    sumDownChange_(0.0),
    115115    sumUpChange_(0.0),
    116     sumDownCostSquared_(0.0),
    117     sumUpCostSquared_(0.0),
     116    downShadowPrice_(0.0),
     117    upShadowPrice_(0.0),
    118118    sumDownDecrease_(0.0),
    119119    sumUpDecrease_(0.0),
     
    148148    sumDownChange_(0.0),
    149149    sumUpChange_(0.0),
    150     sumDownCostSquared_(0.0),
    151     sumUpCostSquared_(0.0),
     150    downShadowPrice_(0.0),
     151    upShadowPrice_(0.0),
    152152    sumDownDecrease_(0.0),
    153153    sumUpDecrease_(0.0),
     
    213213    sumDownChange_(0.0),
    214214    sumUpChange_(0.0),
    215     sumDownCostSquared_(0.0),
    216     sumUpCostSquared_(0.0),
     215    downShadowPrice_(0.0),
     216    upShadowPrice_(0.0),
    217217    sumDownDecrease_(0.0),
    218218    sumUpDecrease_(0.0),
     
    284284   sumDownChange_(rhs.sumDownChange_),
    285285   sumUpChange_(rhs.sumUpChange_),
    286    sumDownCostSquared_(rhs.sumDownCostSquared_),
    287    sumUpCostSquared_(rhs.sumUpCostSquared_),
     286   downShadowPrice_(rhs.downShadowPrice_),
     287   upShadowPrice_(rhs.upShadowPrice_),
    288288   sumDownDecrease_(rhs.sumDownDecrease_),
    289289   sumUpDecrease_(rhs.sumUpDecrease_),
     
    327327    sumDownChange_ = rhs.sumDownChange_;
    328328    sumUpChange_ = rhs.sumUpChange_;
    329     sumDownCostSquared_ = rhs.sumDownCostSquared_;
    330     sumUpCostSquared_ = rhs.sumUpCostSquared_;
     329    downShadowPrice_ = rhs.downShadowPrice_;
     330    upShadowPrice_ = rhs.upShadowPrice_;
    331331    sumDownDecrease_ = rhs.sumDownDecrease_;
    332332    sumUpDecrease_ = rhs.sumUpDecrease_;
     
    364364  sumDownChange_ = otherObject->sumDownChange_;
    365365  sumUpChange_ = otherObject->sumUpChange_;
    366   sumDownCostSquared_ = otherObject->sumDownCostSquared_;
    367   sumUpCostSquared_ = otherObject->sumUpCostSquared_;
     366  downShadowPrice_ = otherObject->downShadowPrice_;
     367  upShadowPrice_ = otherObject->upShadowPrice_;
    368368  sumDownDecrease_ = otherObject->sumDownDecrease_;
    369369  sumUpDecrease_ = otherObject->sumUpDecrease_;
     
    434434  sumDownChange_ += rhsObject->sumDownChange_-baseObject->sumDownChange_;
    435435  sumUpChange_ += rhsObject->sumUpChange_-baseObject->sumUpChange_;
    436   sumDownCostSquared_ += rhsObject->sumDownCostSquared_-baseObject->sumDownCostSquared_;
    437   sumUpCostSquared_ += rhsObject->sumUpCostSquared_-baseObject->sumUpCostSquared_;
     436  downShadowPrice_ = 0.0;
     437  upShadowPrice_ = 0.0;
    438438  sumDownDecrease_ += rhsObject->sumDownDecrease_-baseObject->sumDownDecrease_;
    439439  sumUpDecrease_ += rhsObject->sumUpDecrease_-baseObject->sumUpDecrease_;
     
    478478  if (sumUpChange_!= otherObject->sumUpChange_)
    479479    okay=false;
    480   if (sumDownCostSquared_!= otherObject->sumDownCostSquared_)
    481     okay=false;
    482   if (sumUpCostSquared_!= otherObject->sumUpCostSquared_)
     480  if (downShadowPrice_!= otherObject->downShadowPrice_)
     481    okay=false;
     482  if (upShadowPrice_!= otherObject->upShadowPrice_)
    483483    okay=false;
    484484  if (sumDownDecrease_!= otherObject->sumDownDecrease_)
     
    557557      // Lower bound active
    558558      lastUpDecrease_++;
    559       sumDownCostSquared_ += djValue;
    560559    }
    561560  } else if (djValue<-1.0e-6) {
     
    564563      // Upper bound active
    565564      lastUpDecrease_++;
    566       sumUpCostSquared_ -= djValue;
    567565    }
    568566  }
     
    619617#endif
    620618#endif
    621   if (number>0.0)
    622     downCost *= sum / number;
    623   else
    624     downCost  *=  downDynamicPseudoCost_;
     619#if MOD_SHADOW==0
     620  if (!downShadowPrice_) {
     621    if (number>0.0)
     622      downCost *= sum / number;
     623    else
     624      downCost  *=  downDynamicPseudoCost_;
     625  } else if (downShadowPrice_>0.0) {
     626    downCost *= downShadowPrice_;
     627  } else {
     628    downCost *= (downDynamicPseudoCost_-downShadowPrice_);
     629  }
     630#else
     631  if (downShadowPrice_<=0.0) {
     632    if (number>0.0)
     633      downCost *= sum / number;
     634    else
     635      downCost  *=  downDynamicPseudoCost_;
     636  } else {
     637    downCost *= downShadowPrice_;
     638  }
     639#endif
    625640  double upCost = CoinMax((above-value),0.0);
    626641#if TYPE2==0
     
    642657#endif
    643658#endif
    644   if (number>0.0)
    645     upCost *= sum / number;
    646   else
    647     upCost  *=  upDynamicPseudoCost_;
     659#if MOD_SHADOW==0
     660  if (!upShadowPrice_) {
     661    if (number>0.0)
     662      upCost *= sum / number;
     663    else
     664      upCost  *=  upDynamicPseudoCost_;
     665  } else if (upShadowPrice_>0.0) {
     666    upCost *= upShadowPrice_;
     667  } else {
     668    upCost *= (upDynamicPseudoCost_-upShadowPrice_);
     669  }
     670#else
     671  if (upShadowPrice_<=0.0) {
     672    if (number>0.0)
     673      upCost *= sum / number;
     674    else
     675      upCost  *=  upDynamicPseudoCost_;
     676  } else {
     677    upCost *= upShadowPrice_;
     678  }
     679#endif
    648680  if (downCost>=upCost)
    649681    preferredWay=1;
     
    660692    upCost *= ratio;
    661693    if ((lastUpDecrease_%100)==-1)
    662       printf("col %d total %d djtimes %d down %g up %g\n",
    663              columnNumber_,lastDownDecrease_,lastUpDecrease_,
    664              sumDownCostSquared_,sumUpCostSquared_);
     694      printf("col %d total %d djtimes %d\n",
     695             columnNumber_,lastDownDecrease_,lastUpDecrease_);
    665696  }
    666697#endif
     
    11191150  //print(1,0.5);
    11201151  assert (downDynamicPseudoCost_>1.0e-40&&upDynamicPseudoCost_>1.0e-40);
     1152#if MOD_SHADOW>1
     1153  if (upShadowPrice_>0.0&&numberTimesDown_>=numberBeforeTrust_
     1154      &&numberTimesUp_>=numberBeforeTrust_) {
     1155    // Set negative
     1156    upShadowPrice_=-upShadowPrice_;
     1157    assert (downShadowPrice_>0.0);
     1158    downShadowPrice_ = - downShadowPrice_;
     1159  }
     1160#endif
    11211161}
    11221162// Updates stuff like pseudocosts after mini branch and bound
     
    11611201    if (numberTimesDown_) {
    11621202      meanDown = sumDownCost_/static_cast<double> (numberTimesDown_);
    1163       devDown = meanDown*meanDown + sumDownCostSquared_ -
    1164         2.0*meanDown*sumDownCost_;
     1203      devDown = meanDown*meanDown - 2.0*meanDown*sumDownCost_;
    11651204      if (devDown>=0.0)
    11661205        devDown = sqrt(devDown);
     
    11701209    if (numberTimesUp_) {
    11711210      meanUp = sumUpCost_/static_cast<double> (numberTimesUp_);
    1172       devUp = meanUp*meanUp + sumUpCostSquared_ -
    1173         2.0*meanUp*sumUpCost_;
     1211      devUp = meanUp*meanUp - 2.0*meanUp*sumUpCost_;
    11741212      if (devUp>=0.0)
    11751213        devUp = sqrt(devUp);
  • trunk/Cbc/src/CbcBranchDynamic.hpp

    r1205 r1224  
    9797  void setUpDynamicPseudoCost(double value);
    9898
     99  /// Down pseudo shadow price cost
     100  inline double downShadowPrice() const
     101  { return downShadowPrice_;}
     102  /// Set down pseudo shadow price cost
     103  inline void setDownShadowPrice(double value)
     104  { downShadowPrice_ = value;}
     105  /// Up pseudo shadow price cost
     106  inline double upShadowPrice() const
     107  { return upShadowPrice_;}
     108  /// Set up pseudo shadow price cost
     109  inline void setUpShadowPrice(double value)
     110  { upShadowPrice_ = value;}
     111
    99112  /// Up down separator
    100113  inline double upDownSeparator() const
     
    112125  /// Add to down sum cost and set last and square
    113126  inline void addToSumDownCost(double value)
    114   { sumDownCost_+=value;lastDownCost_=value;sumDownCostSquared_ += value*value;}
     127  { sumDownCost_+=value;lastDownCost_=value;}
    115128
    116129  /// Up sum cost
     
    122135  /// Add to up sum cost and set last and square
    123136  inline void addToSumUpCost(double value)
    124   { sumUpCost_+=value;lastUpCost_=value;sumUpCostSquared_ += value*value;}
     137  { sumUpCost_+=value;lastUpCost_=value;}
    125138
    126139  /// Down sum change
     
    257270  /// Sum of all changes to x when going up
    258271  double sumUpChange_;
    259   /// Sum down cost from strong or actual squared
    260   mutable double sumDownCostSquared_;
    261   /// Sum up cost from strong or actual squared
    262   mutable double sumUpCostSquared_;
     272  /// Current pseudo-shadow price estimate down
     273  mutable double downShadowPrice_;
     274  /// Current pseudo-shadow price estimate up
     275  mutable double upShadowPrice_;
    263276  /// Sum down decrease number infeasibilities from strong or actual
    264277  double sumDownDecrease_;
  • trunk/Cbc/src/CbcCutGenerator.cpp

    r1221 r1224  
    543543      }
    544544    }
    545     {
     545    if (!atSolution()) {
    546546      int numberRowCutsAfter = cs.sizeRowCuts() ;
    547547      int k ;
  • trunk/Cbc/src/CbcHeuristic.cpp

    r1221 r1224  
    369369    double probability = numerator / denominator;
    370370    double randomNumber = randomNumberGenerator_.randomDouble();
    371     if (when_>2&&when_<8) {
     371    int when = when_%100;
     372    if (when>2&&when<8) {
    372373      /* JJF adjustments
    373374         3 only at root and if no solution
     
    377378         7 run up to 2 times if solution found 4 otherwise
    378379      */
    379       switch(when_) {
     380      switch(when) {
    380381      case 3:
    381382      default:
     
    15441545    validate();
    15451546  }
     1547  down_ = NULL;
     1548  up_ = NULL;
     1549  equal_ = NULL;
    15461550  seed_=7654321;
    15471551}
     
    24002404CbcRounding::validate()
    24012405{
    2402   if (model_&&when()<10) {
     2406  if (model_&&(when()%100)<10) {
    24032407    if (model_->numberIntegers()!=
    24042408        model_->numberObjects()&&(model_->numberObjects()||
     
    26142618CbcHeuristicPartial::validate()
    26152619{
    2616   if (model_&&when()<10) {
     2620  if (model_&&(when()%100)<10) {
    26172621    if (model_->numberIntegers()!=
    26182622        model_->numberObjects())
  • trunk/Cbc/src/CbcHeuristicDive.cpp

    r1221 r1224  
    99#include "CbcHeuristicDive.hpp"
    1010#include "CbcStrategy.hpp"
     11#include "OsiAuxInfo.hpp"
    1112#include  "CoinTime.hpp"
    1213
     
    2526  downLocks_ =NULL;
    2627  upLocks_ = NULL;
     28  downArray_ =NULL;
     29  upArray_ = NULL;
    2730  percentageToFix_ = 0.2;
    2831  maxIterations_ = 100;
     
    3942  downLocks_ =NULL;
    4043  upLocks_ = NULL;
     44  downArray_ =NULL;
     45  upArray_ = NULL;
    4146  // Get a copy of original matrix
    4247  assert(model.solver());
     
    6166  delete [] downLocks_;
    6267  delete [] upLocks_;
     68  assert (!downArray_);
    6369}
    6470
     
    99105  maxTime_(rhs.maxTime_)
    100106{
     107  downArray_ =NULL;
     108  upArray_ = NULL;
    101109  if (rhs.downLocks_) {
    102110    int numberIntegers = model_->numberIntegers();
     
    218226
    219227  OsiSolverInterface * solver = cloneBut(6); // was model_->solver()->clone();
     228# ifdef COIN_HAS_CLP
     229  OsiClpSolverInterface * clpSolver
     230    = dynamic_cast<OsiClpSolverInterface *> (solver);
     231  if (clpSolver) {
     232    // say give up easily
     233    ClpSimplex * clpSimplex = clpSolver->getModelPtr();
     234    clpSimplex->setMoreSpecialOptions(clpSimplex->moreSpecialOptions()|64);
     235  }
     236# endif
    220237  const double * lower = solver->getColLower();
    221238  const double * upper = solver->getColUpper();
     
    240257  const CoinBigIndex * columnStart = matrix_.getVectorStarts();
    241258  const int * columnLength = matrix_.getVectorLengths();
     259#ifdef DIVE_FIX_BINARY_VARIABLES
    242260  // Row copy
    243   //const double * elementByRow = matrixByRow_.getElements();
    244   //const int * column = matrixByRow_.getIndices();
    245   //const CoinBigIndex * rowStart = matrixByRow_.getVectorStarts();
    246   //const int * rowLength = matrixByRow_.getVectorLengths();
     261  const double * elementByRow = matrixByRow_.getElements();
     262  const int * column = matrixByRow_.getIndices();
     263  const CoinBigIndex * rowStart = matrixByRow_.getVectorStarts();
     264  const int * rowLength = matrixByRow_.getVectorLengths();
     265#endif
    247266
    248267  // Get solution array for heuristic solution
     
    255274  double* originalBound = new double [numberIntegers];
    256275  bool * fixedAtLowerBound = new bool [numberIntegers];
    257   PseudoReducedCost * candidate = NULL;
    258   if(binVarIndex_.size())
    259     candidate = new PseudoReducedCost [binVarIndex_.size()];
    260 
    261   const int maxNumberAtBoundToFix = static_cast<int> (floor(percentageToFix_ * numberIntegers));
     276  PseudoReducedCost * candidate = new PseudoReducedCost [numberIntegers];
     277  double * random = new double [numberIntegers];
     278
     279  int maxNumberAtBoundToFix = static_cast<int> (floor(percentageToFix_ * numberIntegers));
    262280
    263281  // count how many fractional variables
    264282  int numberFractionalVariables = 0;
    265283  for (int i=0; i<numberIntegers; i++) {
     284    random[i]=randomNumberGenerator_.randomDouble()+0.3;
    266285    int iColumn = integerVariable[i];
    267286    double value=newSolution[iColumn];
     
    271290  }
    272291
    273 #ifdef DIVE_FIX_BINARY_VARIABLES
    274   const double* reducedCost = solver->getReducedCost();
    275 #endif
     292  const double* reducedCost = NULL;
     293  // See if not NLP
     294  if(model_->solverCharacteristics()->reducedCostsAccurate())
     295    reducedCost = solver->getReducedCost();
    276296
    277297  int iteration = 0;
    278298  while(numberFractionalVariables) {
    279299    iteration++;
     300   
     301    // initialize any data
     302    initializeData();
    280303
    281304    // select a fractional variable to bound
     
    356379    if(binVarIndex_.size()) {
    357380      int cnt = 0;
    358       for (int j=0; j<(int)binVarIndex_.size(); j++) {
     381      int n = static_cast<int>(binVarIndex_.size());
     382      for (int j=0; j<n; j++) {
    359383        int iColumn1 = binVarIndex_[j];
    360384        double value = newSolution[iColumn1];
    361         double maxPseudoReducedCost = 0.0;
    362385        if(fabs(value)<=integerTolerance &&
    363386           lower[iColumn1] != upper[iColumn1]) {
     387          double maxPseudoReducedCost = 0.0;
    364388#ifdef DIVE_DEBUG
    365389          std::cout<<"iColumn1 = "<<iColumn1<<", value = "<<value<<std::endl;
    366390#endif
    367391          int iRow = vbRowIndex_[j];
     392          double chosenValue=0.0;
    368393          for (int k=rowStart[iRow];k<rowStart[iRow]+rowLength[iRow];k++) {
    369394            int iColumn2 = column[k];
     
    373398            if(iColumn1 != iColumn2) {
    374399              double pseudoReducedCost = fabs(reducedCost[iColumn2] *
    375                                               elementByRow[iColumn2] /
    376                                               elementByRow[iColumn1]);
    377 #ifdef DIVE_DEBUG
     400                                              elementByRow[k]);
     401#ifdef DIVE_DEBUG
     402              int k2;
     403              for (k2=rowStart[iRow];k2<rowStart[iRow]+rowLength[iRow];k2++) {
     404                if (column[k2]==iColumn1)
     405                  break;
     406              }
    378407              std::cout<<"reducedCost["<<iColumn2<<"] = "
    379408                       <<reducedCost[iColumn2]
    380                        <<", elementByRow["<<iColumn2<<"] = "<<elementByRow[iColumn2]
    381                        <<", elementByRow["<<iColumn1<<"] = "<<elementByRow[iColumn1]
     409                       <<", elementByRow["<<iColumn2<<"] = "<<elementByRow[k]
     410                       <<", elementByRow["<<iColumn1<<"] = "<<elementByRow[k2]
    382411                       <<", pseudoRedCost = "<<pseudoReducedCost
    383412                       <<std::endl;
     
    385414              if(pseudoReducedCost > maxPseudoReducedCost)
    386415                maxPseudoReducedCost = pseudoReducedCost;
     416            } else {
     417              // save value
     418              chosenValue = fabs(elementByRow[k]);
    387419            }
    388420          }
     421          assert (chosenValue);
     422          maxPseudoReducedCost /= chosenValue;
    389423#ifdef DIVE_DEBUG
    390424          std::cout<<", maxPseudoRedCost = "<<maxPseudoReducedCost<<std::endl;
     
    414448
    415449    // fix other integer variables that are at their bounds
    416     for (int i=0; i<numberIntegers; i++) {
    417       int iColumn = integerVariable[i];
    418       double value=newSolution[iColumn];
    419       if(fabs(floor(value+0.5)-value)<=integerTolerance &&
    420          numberAtBoundFixed < maxNumberAtBoundToFix) {
    421         // fix the variable at one of its bounds
    422         if (fabs(lower[iColumn]-value)<=integerTolerance &&
    423             lower[iColumn] != upper[iColumn]) {
    424           columnFixed[numberAtBoundFixed] = iColumn;
    425           originalBound[numberAtBoundFixed] = upper[iColumn];
    426           fixedAtLowerBound[numberAtBoundFixed] = true;
    427           solver->setColUpper(iColumn, lower[iColumn]);
    428           numberAtBoundFixed++;
    429         }
    430         else if(fabs(upper[iColumn]-value)<=integerTolerance &&
    431             lower[iColumn] != upper[iColumn]) {
    432           columnFixed[numberAtBoundFixed] = iColumn;
    433           originalBound[numberAtBoundFixed] = lower[iColumn];
    434           fixedAtLowerBound[numberAtBoundFixed] = false;
    435           solver->setColLower(iColumn, upper[iColumn]);
    436           numberAtBoundFixed++;
    437         }
    438         if(numberAtBoundFixed == maxNumberAtBoundToFix)
    439           break;
     450    int cnt=0;
     451#ifdef GAP
     452    double gap=1.0e30;
     453#endif
     454    if (reducedCost&&true) {
     455#ifdef GAP
     456      double cutoff = model_->getCutoff() ;
     457      if (cutoff<1.0e20&&false) {
     458        double direction = solver->getObjSense() ;
     459        gap = cutoff - solver->getObjValue()*direction ;
     460        gap *= 0.1; // Fix more if plausible
     461        double tolerance;
     462        solver->getDblParam(OsiDualTolerance,tolerance) ;
     463        if (gap<=0.0)
     464          gap = tolerance;
     465        gap += 100.0*tolerance;
     466      }
     467      int nOverGap=0;
     468#endif
     469      int numberFree=0;
     470      int numberFixed=0;
     471      for (int i=0; i<numberIntegers; i++) {
     472        int iColumn = integerVariable[i];
     473        if (upper[iColumn]>lower[iColumn]) {
     474          numberFree++;
     475          double value=newSolution[iColumn];
     476          if(fabs(floor(value+0.5)-value)<=integerTolerance) {
     477            candidate[cnt].var = iColumn;
     478            candidate[cnt++].pseudoRedCost =
     479              fabs(reducedCost[iColumn]*random[i]);
     480#ifdef GAP
     481            if (fabs(reducedCost[iColumn])>gap)
     482              nOverGap++;
     483#endif
     484          }
     485        } else {
     486          numberFixed++;
     487        }
     488      }
     489#ifdef GAP
     490      int nLeft = maxNumberAtBoundToFix-numberAtBoundFixed;
     491#ifdef CLP_INVESTIGATE
     492      printf("cutoff %g obj %g nover %d - %d free, %d fixed\n",
     493             cutoff,solver->getObjValue(),nOverGap,numberFree,numberFixed);
     494#endif
     495      if (nOverGap>nLeft&&true) {
     496        nOverGap = CoinMin(nOverGap,nLeft+maxNumberAtBoundToFix/2);
     497        maxNumberAtBoundToFix += nOverGap-nLeft;
     498      }
     499#else
     500#ifdef CLP_INVESTIGATE
     501      printf("cutoff %g obj %g - %d free, %d fixed\n",
     502             model_->getCutoff(),solver->getObjValue(),numberFree,numberFixed);
     503#endif
     504#endif
     505    } else {
     506      for (int i=0; i<numberIntegers; i++) {
     507        int iColumn = integerVariable[i];
     508        if (upper[iColumn]>lower[iColumn]) {
     509          double value=newSolution[iColumn];
     510          if(fabs(floor(value+0.5)-value)<=integerTolerance) {
     511            candidate[cnt].var = iColumn;
     512            candidate[cnt++].pseudoRedCost = numberIntegers-i;
     513          }
     514        }
     515      }
     516    }
     517    std::sort(candidate, candidate+cnt, compareBinaryVars);
     518    for (int i=0; i<cnt; i++) {
     519      int iColumn = candidate[i].var;
     520      if (upper[iColumn]>lower[iColumn]) {
     521        double value=newSolution[iColumn];
     522        if(fabs(floor(value+0.5)-value)<=integerTolerance &&
     523           numberAtBoundFixed < maxNumberAtBoundToFix) {
     524          // fix the variable at one of its bounds
     525          if (fabs(lower[iColumn]-value)<=integerTolerance) {
     526            columnFixed[numberAtBoundFixed] = iColumn;
     527            originalBound[numberAtBoundFixed] = upper[iColumn];
     528            fixedAtLowerBound[numberAtBoundFixed] = true;
     529            solver->setColUpper(iColumn, lower[iColumn]);
     530            numberAtBoundFixed++;
     531          }
     532          else if(fabs(upper[iColumn]-value)<=integerTolerance) {
     533            columnFixed[numberAtBoundFixed] = iColumn;
     534            originalBound[numberAtBoundFixed] = lower[iColumn];
     535            fixedAtLowerBound[numberAtBoundFixed] = false;
     536            solver->setColLower(iColumn, upper[iColumn]);
     537            numberAtBoundFixed++;
     538          }
     539          if(numberAtBoundFixed == maxNumberAtBoundToFix)
     540            break;
     541        }
    440542      }
    441543    }
     
    633735  delete [] candidate;
    634736  delete [] rowActivity;
     737  delete [] random;
     738  delete [] downArray_;
     739  downArray_=NULL;
     740  delete [] upArray_;
     741  upArray_=NULL;
    635742  delete solver;
    636743  return returnCode;
     
    641748CbcHeuristicDive::validate()
    642749{
    643   if (model_&&when()<10) {
     750  if (model_&&(when()%100)<10) {
    644751    if (model_->numberIntegers()!=
    645752        model_->numberObjects()&&(model_->numberObjects()||
     
    810917
    811918{
    812   return 0; // temp
    813 #if 0
    814   if(!solverCharacteristics_->reducedCostsAccurate())
     919  //return 0; // temp
     920#if 1
     921  if(!model_->solverCharacteristics()->reducedCostsAccurate())
    815922    return 0; //NLP
    816923#endif
    817924  double cutoff = model_->getCutoff() ;
     925  if (cutoff>1.0e20)
     926    return 0;
    818927#ifdef DIVE_DEBUG
    819928  std::cout<<"cutoff = "<<cutoff<<std::endl;
     
    821930  double direction = solver->getObjSense() ;
    822931  double gap = cutoff - solver->getObjValue()*direction ;
     932  gap *= 0.5; // Fix more
    823933  double tolerance;
    824934  solver->getDblParam(OsiDualTolerance,tolerance) ;
  • trunk/Cbc/src/CbcHeuristicDive.hpp

    r1200 r1224  
    8282  virtual bool canHeuristicRun();
    8383
    84   /// Selects the next variable to branch on
    85   /** Returns true if all the fractional variables can be trivially
     84  /** Selects the next variable to branch on
     85      Returns true if all the fractional variables can be trivially
    8686      rounded. Returns false, if there is at least one fractional variable
    8787      that is not trivially roundable. In this case, the bestColumn
     
    9292                                      int& bestColumn,
    9393                                      int& bestRound) = 0;
     94  /** Initializes any data which is going to be used repeatedly
     95      in selectVariableToBranch */
     96  virtual void initializeData() {};
    9497
    9598  /// Perform reduced cost fixing on integer variables
     
    110113  // Up locks
    111114  unsigned short * upLocks_;
     115
     116  /// Extra down array (number Integers long)
     117  double * downArray_;
     118
     119  /// Extra up array (number Integers long)
     120  double * upArray_;
    112121
    113122  // Indexes of binary variables with 0 objective coefficient
  • trunk/Cbc/src/CbcHeuristicDivePseudoCost.cpp

    r1173 r1224  
    99#include "CbcHeuristicDivePseudoCost.hpp"
    1010#include "CbcStrategy.hpp"
     11#include "CbcBranchDynamic.hpp"
    1112
    1213// Default Constructor
     
    7677
    7778  // get pseudo costs
    78   double * pseudoCostDown = new double[numberIntegers];
    79   double * pseudoCostUp = new double[numberIntegers];
    80   model_->fillPseudoCosts(pseudoCostDown, pseudoCostUp);
     79  double * pseudoCostDown = downArray_;
     80  double * pseudoCostUp = upArray_;
    8181
    8282  bestColumn = -1;
     
    139139  }
    140140
    141   delete [] pseudoCostDown;
    142   delete [] pseudoCostUp;
    143 
    144141  return allTriviallyRoundableSoFar;
    145142}
     143void
     144CbcHeuristicDivePseudoCost::initializeData()
     145{
     146  int numberIntegers = model_->numberIntegers();
     147  if (!downArray_) {
     148    downArray_ = new double [numberIntegers];
     149    upArray_ = new double [numberIntegers];
     150  }
     151  // get pseudo costs
     152  model_->fillPseudoCosts(downArray_, upArray_);
     153  int diveOptions = when_/100;
     154  if (diveOptions) {
     155    // pseudo shadow prices
     156    int k = diveOptions%100;
     157    if (diveOptions>=100)
     158      k +=32;
     159    model_->pseudoShadow(k-1);
     160    int numberInts=CoinMin(model_->numberObjects(),numberIntegers);
     161    OsiObject ** objects = model_->objects();
     162    for (int i=0;i<numberInts;i++) {
     163      CbcSimpleIntegerDynamicPseudoCost * obj1 =
     164        dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(objects[i]) ;
     165      if (obj1) {
     166        int iColumn = obj1->columnNumber();
     167        double downPseudoCost = obj1->downDynamicPseudoCost();
     168        double downShadow = obj1->downShadowPrice();
     169        double upPseudoCost = obj1->upDynamicPseudoCost();
     170        double upShadow = obj1->upShadowPrice();
     171        downPseudoCost = CoinMax(downPseudoCost,downShadow);
     172        downPseudoCost = CoinMax(downPseudoCost,0.001*upShadow);
     173        downArray_[i]=downPseudoCost;
     174        upPseudoCost = CoinMax(upPseudoCost,upShadow);
     175        upPseudoCost = CoinMax(upPseudoCost,0.001*downShadow);
     176        upArray_[i]=upPseudoCost;
     177      }
     178    }
     179  }
     180}
  • trunk/Cbc/src/CbcHeuristicDivePseudoCost.hpp

    r1173 r1224  
    4444                                      int& bestColumn,
    4545                                      int& bestRound);
     46  /** Initializes any data which is going to be used repeatedly
     47      in selectVariableToBranch */
     48  virtual void initializeData() ;
     49
    4650
    4751};
  • trunk/Cbc/src/CbcHeuristicFPump.cpp

    r1223 r1224  
    279279      iterationRatio_;
    280280  int totalNumberIterations=0;
    281   int numberIterationsPass1=-1;
     281  int averageIterationsPerTry=-1;
    282282  int numberIterationsLastPass=0;
    283283  // 1. initially check 0-1
     
    372372  double * firstPerturbedObjective = NULL;
    373373  double * firstPerturbedSolution = NULL;
     374  double firstPerturbedValue=COIN_DBL_MAX;
    374375  if (when_>=11&&when_<=15) {
    375376    fixInternal = when_ >11&&when_<15;
     
    484485        lp->setSpecialOptions(options|8192);
    485486        //lp->setSpecialOptions(options|0x01000000);
     487#ifdef CLP_INVESTIGATE
     488        clpSolver->setHintParam(OsiDoReducePrint,false,OsiHintTry);
     489        lp->setLogLevel(CoinMax(1,lp->logLevel()));
     490#endif
    486491      }
    487492    }
     
    650655        }
    651656      }
    652       if (numberIterationsPass1>=0) {
     657      if (averageIterationsPerTry>=0) {
    653658        int n = totalNumberIterations - numberIterationsLastPass;
    654659        double perPass = totalNumberIterations/
    655660          (totalNumberPasses+numberPasses+1.0e-5);
    656661        perPass /= (solver->getNumRows()+numberColumns);
    657         double test = moreIterations ? 0.3 : 0.0;
    658         if (n>CoinMax(20000,3*numberIterationsPass1)
     662        double test = moreIterations ? 0.3 : 0.05;
     663        if (n>CoinMax(20000,3*averageIterationsPerTry)
    659664            &&(switches_&2)==0&&maximumPasses<200&&perPass>test) {
    660665          exitAll=true;
     
    10831088                  } else if (objective[iColumn]<0.0) {
    10841089                    if (basis->getStructStatus(iColumn)==
    1085                         CoinWarmStartBasis::atUpperBound) {
     1090                        CoinWarmStartBasis::atLowerBound) {
    10861091                      solution[iColumn]=upper[iColumn];
    10871092                      basis->setStructStatus(iColumn,CoinWarmStartBasis::atUpperBound);
     
    11301135            // and solution
    11311136            solver->setColSolution(firstPerturbedSolution);
    1132             if (secondPassOpt==2||secondPassOpt==5)
     1137            //if (secondPassOpt==2||secondPassOpt==5||
     1138            if(firstPerturbedValue>cutoff)
    11331139              solver->setHintParam(OsiDoDualInResolve,true); // dual may be better
    11341140          }
     
    11381144            exitAll=true;
    11391145            break;
    1140           }
    1141           if (numberPasses==1&&secondPassOpt) {
    1142             if (numberTries==1||secondPassOpt>3) {
    1143               // save basis
    1144               CoinWarmStartBasis * basis =
    1145                 dynamic_cast<CoinWarmStartBasis *>(solver->getWarmStart()) ;
    1146               if (basis) {
    1147                 saveBasis = * basis;
    1148                 delete basis;
    1149               }
    1150               delete [] firstPerturbedObjective;
    1151               delete [] firstPerturbedSolution;
    1152               firstPerturbedObjective = CoinCopyOfArray(solver->getObjCoefficients(),numberColumns);
    1153               firstPerturbedSolution = CoinCopyOfArray(solver->getColSolution(),numberColumns);
    1154             }
    11551146          }
    11561147          solver->setHintParam(OsiDoDualInResolve,takeHint);
     
    11711162            }
    11721163            newTrueSolutionValue *= direction;
     1164            if (numberPasses==1&&secondPassOpt) {
     1165              if (numberTries==1||secondPassOpt>3) {
     1166                // save basis
     1167                CoinWarmStartBasis * basis =
     1168                  dynamic_cast<CoinWarmStartBasis *>(solver->getWarmStart()) ;
     1169                if (basis) {
     1170                  saveBasis = * basis;
     1171                  delete basis;
     1172                }
     1173                delete [] firstPerturbedObjective;
     1174                delete [] firstPerturbedSolution;
     1175                firstPerturbedObjective = CoinCopyOfArray(solver->getObjCoefficients(),numberColumns);
     1176                firstPerturbedSolution = CoinCopyOfArray(solver->getColSolution(),numberColumns);
     1177                firstPerturbedValue=newTrueSolutionValue;
     1178              }
     1179            }
    11731180            if (newNumberInfeas&&newNumberInfeas<15) {
    11741181#if 0
     
    17471754          if (fixContinuous&&nFixC+nFixC2>0) {
    17481755            // may be able to do even better
     1756            int nFixed=0;
    17491757            const double * lower = model_->solver()->getColLower();
    17501758            const double * upper = model_->solver()->getColUpper();
    17511759            for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     1760              double value = newSolution[iColumn];
    17521761              if (newSolver->isInteger(iColumn)) {
    1753                 double value=floor(newSolution[iColumn]+0.5);
     1762                value=floor(newSolution[iColumn]+0.5);
    17541763                newSolver->setColLower(iColumn,value);
    17551764                newSolver->setColUpper(iColumn,value);
     1765                nFixed++;
    17561766              } else {
    17571767                newSolver->setColLower(iColumn,lower[iColumn]);
    17581768                newSolver->setColUpper(iColumn,upper[iColumn]);
    1759               }
    1760             }
     1769                if (value<lower[iColumn])
     1770                  value=lower[iColumn];
     1771                else if (value>upper[iColumn])
     1772                  value=upper[iColumn];
     1773               
     1774              }
     1775              newSolution[iColumn]=value;
     1776            }
     1777            newSolver->setColSolution(newSolution);
     1778#define CLP_INVESTIGATE2
     1779#ifdef CLP_INVESTIGATE2
     1780            {
     1781              // check
     1782              // get row activities
     1783              int numberRows = newSolver->getNumRows();
     1784              double * rowActivity = new double[numberRows];
     1785              memset(rowActivity,0,numberRows*sizeof(double));
     1786              newSolver->getMatrixByCol()->times(newSolution,rowActivity) ;
     1787              double largestInfeasibility =primalTolerance;
     1788              double sumInfeasibility=0.0;
     1789              int numberBadRows=0;
     1790              const double * rowLower = newSolver->getRowLower();
     1791              const double * rowUpper = newSolver->getRowUpper();
     1792              for (i=0 ; i < numberRows ; i++) {
     1793                double value;
     1794                value = rowLower[i]-rowActivity[i];
     1795                if (value>primalTolerance) {
     1796                  numberBadRows++;
     1797                  largestInfeasibility = CoinMax(largestInfeasibility,value);
     1798                  sumInfeasibility += value;
     1799                }
     1800                value = rowActivity[i]-rowUpper[i];
     1801                if (value>primalTolerance) {
     1802                  numberBadRows++;
     1803                  largestInfeasibility = CoinMax(largestInfeasibility,value);
     1804                  sumInfeasibility += value;
     1805                }
     1806              }
     1807              printf("%d bad rows, largest inf %g sum %g\n",
     1808                     numberBadRows,largestInfeasibility,sumInfeasibility);
     1809              delete [] rowActivity;
     1810            }
     1811#endif
     1812#ifdef COIN_HAS_CLP
     1813            OsiClpSolverInterface * clpSolver
     1814              = dynamic_cast<OsiClpSolverInterface *> (newSolver);
     1815            if (clpSolver) {
     1816              ClpSimplex * simplex = clpSolver->getModelPtr();
     1817              //simplex->writeBasis("test.bas",true,2);
     1818              //simplex->writeMps("test.mps",2,1);
     1819              if (nFixed*3>numberColumns*2)
     1820                simplex->allSlackBasis(); // may as well go from all slack
     1821              simplex->primal(1);
     1822              clpSolver->setWarmStart(NULL);
     1823            }
     1824#endif
    17611825            newSolver->initialSolve();
    17621826            if (newSolver->isProvenOptimal()) {
     
    18951959          usedColumn[i]=-1;
    18961960      }
    1897       if (!totalNumberPasses)
    1898         numberIterationsPass1 = totalNumberIterations;
     1961      averageIterationsPerTry = totalNumberIterations/numberTries;
    18991962      numberIterationsLastPass =  totalNumberIterations;
    19001963      totalNumberPasses += numberPasses-1;
  • trunk/Cbc/src/CbcModel.cpp

    r1223 r1224  
    11351135    specialOptions_ |= 4096;
    11361136  }
     1137  int saveMoreSpecialOptions = moreSpecialOptions_;
    11371138  if (dynamic_cast<CbcTreeLocal *> (tree_))
    11381139    specialOptions_ |= 4096+8192;
     
    42774278  }
    42784279#endif
     4280  moreSpecialOptions_ = saveMoreSpecialOptions;
    42794281  return ;
    42804282 }
     
    44104412  usedInSolution_(NULL),
    44114413  specialOptions_(0),
     4414  moreSpecialOptions_(0),
    44124415  subTreeModel_(NULL),
    44134416  numberStoppedSubTrees_(0),
     
    45714574  integerInfo_(NULL),
    45724575  specialOptions_(0),
     4576  moreSpecialOptions_(0),
    45734577  subTreeModel_(NULL),
    45744578  numberStoppedSubTrees_(0),
     
    48234827  secondaryStatus_(rhs.secondaryStatus_),
    48244828  specialOptions_(rhs.specialOptions_),
     4829  moreSpecialOptions_(rhs.moreSpecialOptions_),
    48254830  subTreeModel_(rhs.subTreeModel_),
    48264831  numberStoppedSubTrees_(rhs.numberStoppedSubTrees_),
     
    51625167    secondaryStatus_ = rhs.secondaryStatus_;
    51635168    specialOptions_ = rhs.specialOptions_;
     5169    moreSpecialOptions_ = rhs.moreSpecialOptions_;
    51645170    subTreeModel_ = rhs.subTreeModel_;
    51655171    numberStoppedSubTrees_ = rhs.numberStoppedSubTrees_;
     
    55775583  minimumDrop_ = rhs.minimumDrop_;
    55785584  specialOptions_ = rhs.specialOptions_;
     5585  moreSpecialOptions_ = rhs.moreSpecialOptions_;
    55795586  numberStrong_ = rhs.numberStrong_;
    55805587  numberBeforeTrust_ = rhs.numberBeforeTrust_;
     
    65796586*/
    65806587  double objectiveValue = solver_->getObjValue()*solver_->getObjSense();
    6581   if (node)
     6588  if (node) {
    65826589    objectiveValue= node->objectiveValue();
     6590  }
    65836591  int returnCode = resolve(node ? node->nodeInfo() : NULL,1);
    65846592#if COIN_DEVELOP>1
     
    66216629      update.objectNumber_ = iObject;
    66226630      addUpdateInformation(update);
     6631      //#define TIGHTEN_BOUNDS
     6632#ifdef TIGHTEN_BOUNDS
     6633      double cutoff=getCutoff() ;
     6634      if (feasible&&cutoff<1.0e20) {
     6635        int way=cbcobj->way();
     6636        // way is what will be taken next
     6637        way = -way;
     6638        double value=cbcobj->value();
     6639        //const double * lower = solver_->getColLower();
     6640        //const double * upper = solver_->getColUpper();
     6641        double objectiveChange = lastObjective-objectiveValue;
     6642        if (objectiveChange>1.0e-5) {
     6643          CbcIntegerBranchingObject * branch = dynamic_cast <CbcIntegerBranchingObject *>(cbcobj) ;
     6644          assert (branch);
     6645          if (way<0) {
     6646            double down = value-floor(value);
     6647            double changePer = objectiveChange/(down+1.0e-7);
     6648            double distance = (cutoff-objectiveValue)/changePer;
     6649            distance += 1.0e-3;
     6650            if (distance<5.0) {
     6651              double newLower = ceil(value-distance);
     6652              const double * downBounds = branch->downBounds();
     6653              if (newLower>downBounds[0]) {
     6654                //printf("%d way %d bounds %g %g value %g\n",
     6655                //     iColumn,way,lower[iColumn],upper[iColumn],value);
     6656                //printf("B Could increase lower bound on %d from %g to %g\n",
     6657                //     iColumn,downBounds[0],newLower);
     6658                solver_->setColLower(iColumn,newLower);
     6659              }
     6660            }
     6661          } else {
     6662            double up = ceil(value)-value;
     6663            double changePer = objectiveChange/(up+1.0e-7);
     6664            double distance = (cutoff-objectiveValue)/changePer;
     6665            distance += 1.0e-3;
     6666            if (distance<5.0) {
     6667              double newUpper = floor(value+distance);
     6668              const double * upBounds = branch->upBounds();
     6669              if (newUpper<upBounds[1]) {
     6670                //printf("%d way %d bounds %g %g value %g\n",
     6671                //     iColumn,way,lower[iColumn],upper[iColumn],value);
     6672                //printf("B Could decrease upper bound on %d from %g to %g\n",
     6673                //     iColumn,upBounds[1],newUpper);
     6674                solver_->setColUpper(iColumn,newUpper);
     6675              }
     6676            }
     6677          }
     6678        }
     6679      }
     6680#endif
    66236681    } else {
    66246682      OsiIntegerBranchingObject * obj = dynamic_cast<OsiIntegerBranchingObject *> (bobj);
     
    66356693        int branch = obj->firstBranch();
    66366694        if (obj->branchIndex()==2)
    6637           branch = 1-branch;
     6695          branch = 1-branch;
    66386696        assert (branch==0||branch==1);
    66396697        double originalValue=node->objectiveValue();
     
    67066764    clpSolver->setSpecialOptions(saveClpOptions);
    67076765# endif
     6766    setPointers(solver_);
    67086767    return true;
    67096768  }
     
    85288587  }
    85298588#endif
     8589  // make sure pointers are up to date
     8590  setPointers(solver_);
    85308591
    85318592  return feasible ; }
     
    87688829    }
    87698830  }
     8831#ifdef COIN_HAS_CLP
     8832  OsiClpSolverInterface * clpSolver
     8833    = dynamic_cast<OsiClpSolverInterface *> (solver_);
     8834#endif
    87708835/*
    87718836  Reoptimize. Consider the possibility that we should fathom on bounds. But be
     
    87878852      // Pierre pointed out that this is not valid for all solvers
    87888853      // so just do if Clp
    8789       {
    8790         OsiClpSolverInterface * clpSolver
    8791           = dynamic_cast<OsiClpSolverInterface *> (solver_);
     8854      if ((specialOptions_&1)!=0&&onOptimalPath) {
     8855        solver_->writeMpsNative("before-tighten.mps",NULL,NULL,2);
     8856      }
     8857      if (clpSolver&&(!currentNode_||(currentNode_->depth()&2)!=0)&&
     8858          !solverCharacteristics_->solutionAddsCuts())
     8859        nTightened=clpSolver->tightenBounds();
     8860      if (nTightened) {
     8861        //printf("%d bounds tightened\n",nTightened);
    87928862        if ((specialOptions_&1)!=0&&onOptimalPath) {
    8793           solver_->writeMpsNative("before-tighten.mps",NULL,NULL,2);
    8794         }
    8795         if (clpSolver&&(!currentNode_||(currentNode_->depth()&2)!=0)&&
    8796             !solverCharacteristics_->solutionAddsCuts())
    8797           nTightened=clpSolver->tightenBounds();
    8798         if (nTightened) {
    8799           //printf("%d bounds tightened\n",nTightened);
    8800           if ((specialOptions_&1)!=0&&onOptimalPath) {
    8801             const OsiRowCutDebugger *debugger = solver_->getRowCutDebugger() ;
    8802             if (!debugger) {
    8803               // tighten did something???
    8804               solver_->getRowCutDebuggerAlways()->printOptimalSolution(*solver_);
    8805               solver_->writeMpsNative("infeas4.mps",NULL,NULL,2);
    8806               printf("Not on optimalpath aaaa\n");
    8807               //abort();
    8808               onOptimalPath=false;
    8809             }
     8863          const OsiRowCutDebugger *debugger = solver_->getRowCutDebugger() ;
     8864          if (!debugger) {
     8865            // tighten did something???
     8866            solver_->getRowCutDebuggerAlways()->printOptimalSolution(*solver_);
     8867            solver_->writeMpsNative("infeas4.mps",NULL,NULL,2);
     8868            printf("Not on optimalpath aaaa\n");
     8869            //abort();
     8870            onOptimalPath=false;
    88108871          }
    88118872        }
     
    88368897        }
    88378898#ifdef COIN_HAS_CLP
    8838         OsiClpSolverInterface * clpSolver
    8839           = dynamic_cast<OsiClpSolverInterface *> (solver_);
    88408899        if (clpSolver&&feasible&&!numberNodes_&&false) {
    88418900          double direction = solver_->getObjSense() ;
     
    90469105    memcpy(saveUpper,solver_->getColUpper(),numberColumns*sizeof(double));
    90479106  }
     9107#ifdef COIN_HAS_CLP
     9108  if (clpSolver&&!feasible) {
     9109    // make sure marked infeasible
     9110    clpSolver->getModelPtr()->setProblemStatus(1);
     9111  }
     9112#endif
    90489113  int returnStatus = feasible ? 1 : 0;
    90499114  if (strategy_) {
     
    93479412// Fill in useful estimates
    93489413void
    9349 CbcModel::pseudoShadow(double * down, double * up)
     9414CbcModel::pseudoShadow(int iActive)
    93509415{
     9416  assert (iActive<2*8*32&&iActive>-3);
     9417  if (iActive==-1) {
     9418    if (numberNodes_) {
     9419      // zero out
     9420      for (int i=0;i<numberObjects_;i++) {
     9421        CbcSimpleIntegerDynamicPseudoCost * obj1 =
     9422          dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(object_[i]) ;
     9423        if (obj1) {
     9424          assert (obj1->downShadowPrice()>0.0);
     9425#if 0
     9426          obj1->setDownShadowPrice(-1.0e-1*obj1->downShadowPrice());
     9427          obj1->setUpShadowPrice(-1.0e-1*obj1->upShadowPrice());
     9428#else
     9429          obj1->incrementNumberTimesDown();
     9430          obj1->setDownDynamicPseudoCost(1.0e1*obj1->downShadowPrice());
     9431          obj1->setDownShadowPrice(0.0);
     9432          obj1->incrementNumberTimesUp();
     9433          obj1->setUpDynamicPseudoCost(1.0e1*obj1->upShadowPrice());
     9434          obj1->setUpShadowPrice(0.0);
     9435#endif
     9436        }
     9437      }
     9438    }
     9439    return;
     9440  }
     9441  bool doShadow=false;
     9442  if (!iActive||iActive>=32) {
     9443    doShadow=true;
     9444    if (iActive>=32)
     9445      iActive -= 32;
     9446  }
     9447  double * rowWeight =NULL;
     9448  double * columnWeight =NULL;
     9449  int numberColumns = solver_->getNumCols() ;
     9450  int numberRows = solver_->getNumRows() ;
    93519451  // Column copy of matrix
    93529452  const double * element = solver_->getMatrixByCol()->getElements();
     
    93549454  const CoinBigIndex * columnStart = solver_->getMatrixByCol()->getVectorStarts();
    93559455  const int * columnLength = solver_->getMatrixByCol()->getVectorLengths();
     9456  const double * dual = solver_->getRowPrice();
     9457  const double * solution = solver_->getColSolution();
     9458  const double * dj = solver_->getReducedCost();
     9459  bool useMax=false;
     9460  bool useAlpha=false;
     9461  if (iActive) {
     9462    // Use Patel and Chinneck ideas
     9463    rowWeight =new double [numberRows];
     9464    columnWeight =new double [numberColumns];
     9465    // add in active constraints
     9466    double tolerance = 1.0e-5;
     9467    const double *rowLower = getRowLower() ;
     9468    const double *rowUpper = getRowUpper() ;
     9469    const double *rowActivity = solver_->getRowActivity();
     9470    const double * lower = getColLower();
     9471    const double * upper = getColUpper();
     9472    CoinZeroN(rowWeight,numberRows);
     9473    /* 1 A weight 1
     9474       2 B weight 1/sum alpha
     9475       3 L weight 1/number integer
     9476       4 M weight 1/number active integer
     9477       7 O weight 1/number integer and use alpha
     9478       8 P weight 1/number active integer and use alpha
     9479       9 up subtract 8 and use maximum
     9480    */
     9481    if (iActive>8) {
     9482      iActive -=8;
     9483      useMax=true;
     9484    }
     9485    if (iActive>4) {
     9486      iActive -=4;
     9487      useAlpha=true;
     9488    }
     9489    switch (iActive) {
     9490      // A
     9491    case 1:
     9492      for (int iRow=0;iRow<numberRows;iRow++) {
     9493        if (rowActivity[iRow]>rowUpper[iRow]-tolerance||
     9494            rowActivity[iRow]<rowLower[iRow]+tolerance) {
     9495          rowWeight[iRow]=1.0;
     9496        }
     9497      }
     9498      break;
     9499      // B
     9500    case 2:
     9501      for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     9502        if (upper[iColumn]>lower[iColumn]) {
     9503          CoinBigIndex start = columnStart[iColumn];
     9504          CoinBigIndex end = start + columnLength[iColumn];
     9505          for (CoinBigIndex j=start;j<end;j++) {
     9506            int iRow = row[j];
     9507            rowWeight[iRow]+= fabs(element[j]);
     9508          }
     9509        }
     9510      }
     9511      for (int iRow=0;iRow<numberRows;iRow++) {
     9512        if (rowWeight[iRow])
     9513          rowWeight[iRow]=1.0/rowWeight[iRow];
     9514      }
     9515      break;
     9516      // L
     9517    case 3:
     9518      for (int jColumn=0;jColumn<numberIntegers_;jColumn++) {
     9519        int iColumn=integerVariable_[jColumn];
     9520        if (upper[iColumn]>lower[iColumn]) {
     9521          CoinBigIndex start = columnStart[iColumn];
     9522          CoinBigIndex end = start + columnLength[iColumn];
     9523          for (CoinBigIndex j=start;j<end;j++) {
     9524            int iRow = row[j];
     9525            rowWeight[iRow]++;
     9526          }
     9527        }
     9528      }
     9529      for (int iRow=0;iRow<numberRows;iRow++) {
     9530        if (rowWeight[iRow])
     9531          rowWeight[iRow]=1.0/rowWeight[iRow];
     9532      }
     9533      break;
     9534      // M
     9535    case 4:
     9536      for (int jColumn=0;jColumn<numberIntegers_;jColumn++) {
     9537        int iColumn=integerVariable_[jColumn];
     9538        double value = solution[iColumn];
     9539        if (fabs(value-floor(value+0.5))>1.0e-5) {
     9540          CoinBigIndex start = columnStart[iColumn];
     9541          CoinBigIndex end = start + columnLength[iColumn];
     9542          for (CoinBigIndex j=start;j<end;j++) {
     9543            int iRow = row[j];
     9544            rowWeight[iRow]++;
     9545          }
     9546        }
     9547      }
     9548      for (int iRow=0;iRow<numberRows;iRow++) {
     9549        if (rowWeight[iRow])
     9550          rowWeight[iRow]=1.0/rowWeight[iRow];
     9551      }
     9552      break;
     9553    }
     9554    if (doShadow) {
     9555      for (int iRow=0;iRow<numberRows;iRow++) {
     9556        rowWeight[iRow] *= dual[iRow];
     9557      }
     9558    }
     9559    dual=rowWeight;
     9560  }
    93569561  const double *objective = solver_->getObjCoefficients() ;
    9357   int numberColumns = solver_->getNumCols() ;
    93589562  double direction = solver_->getObjSense();
    9359   int iColumn;
    9360   const double * dual = cbcRowPrice_;
    9361   down = new double[numberColumns];
    9362   up = new double[numberColumns];
     9563  double * down = new double[numberColumns];
     9564  double * up = new double[numberColumns];
    93639565  double upSum=1.0e-20;
    93649566  double downSum = 1.0e-20;
    93659567  int numberIntegers=0;
    9366   for (iColumn=0;iColumn<numberColumns;iColumn++) {
    9367     CoinBigIndex start = columnStart[iColumn];
    9368     CoinBigIndex end = start + columnLength[iColumn];
    9369     double upValue = 0.0;
    9370     double downValue = 0.0;
    9371     double value = direction*objective[iColumn];
    9372     if (value) {
    9373       if (value>0.0)
    9374         upValue += value;
    9375       else
    9376         downValue -= value;
    9377     }
    9378     for (CoinBigIndex j=start;j<end;j++) {
    9379       int iRow = row[j];
    9380       value = -dual[iRow];
     9568  if (doShadow) {
     9569    // shadow prices
     9570    if (!useMax) {
     9571      for (int jColumn=0;jColumn<numberIntegers_;jColumn++) {
     9572        int iColumn=integerVariable_[jColumn];
     9573        CoinBigIndex start = columnStart[iColumn];
     9574        CoinBigIndex end = start + columnLength[iColumn];
     9575        double upValue = 0.0;
     9576        double downValue = 0.0;
     9577        double value = direction*objective[iColumn];
     9578        if (value) {
     9579          if (value>0.0)
     9580            upValue += value;
     9581          else
     9582            downValue -= value;
     9583        }
     9584        for (CoinBigIndex j=start;j<end;j++) {
     9585          int iRow = row[j];
     9586          value = -dual[iRow];
     9587          assert (fabs(dual[iRow]<1.0e50));
     9588          if (value) {
     9589            value *= element[j];
     9590            if (value>0.0)
     9591              upValue += value;
     9592            else
     9593              downValue -= value;
     9594          }
     9595        }
     9596        up[iColumn]=upValue;
     9597        down[iColumn]=downValue;
     9598        if (solver_->isInteger(iColumn)) {
     9599          if (!numberNodes_&&handler_->logLevel()>1)
     9600            printf("%d - up %g down %g cost %g\n",
     9601                   iColumn,upValue,downValue,objective[iColumn]);
     9602          upSum += upValue;
     9603          downSum += downValue;
     9604          numberIntegers++;
     9605        }
     9606      }
     9607    } else {
     9608      for (int jColumn=0;jColumn<numberIntegers_;jColumn++) {
     9609        int iColumn=integerVariable_[jColumn];
     9610        CoinBigIndex start = columnStart[iColumn];
     9611        CoinBigIndex end = start + columnLength[iColumn];
     9612        double upValue = 0.0;
     9613        double downValue = 0.0;
     9614        double value = direction*objective[iColumn];
     9615        if (value) {
     9616          if (value>0.0)
     9617            upValue += value;
     9618          else
     9619            downValue -= value;
     9620        }
     9621        for (CoinBigIndex j=start;j<end;j++) {
     9622          int iRow = row[j];
     9623          value = -dual[iRow];
     9624          if (value) {
     9625            value *= element[j];
     9626            if (value>0.0)
     9627              upValue = CoinMax(upValue,value);
     9628            else
     9629              downValue = CoinMax(downValue,-value);
     9630          }
     9631        }
     9632        up[iColumn]=upValue;
     9633        down[iColumn]=downValue;
     9634        if (solver_->isInteger(iColumn)) {
     9635          if (!numberNodes_&&handler_->logLevel()>1)
     9636            printf("%d - up %g down %g cost %g\n",
     9637                   iColumn,upValue,downValue,objective[iColumn]);
     9638          upSum += upValue;
     9639          downSum += downValue;
     9640          numberIntegers++;
     9641        }
     9642      }
     9643    }
     9644  } else {
     9645    for (int jColumn=0;jColumn<numberIntegers_;jColumn++) {
     9646      int iColumn=integerVariable_[jColumn];
     9647      CoinBigIndex start = columnStart[iColumn];
     9648      CoinBigIndex end = start + columnLength[iColumn];
     9649      double upValue = 0.0;
     9650      double downValue = 0.0;
     9651      double value = direction*objective[iColumn];
    93819652      if (value) {
    9382         value *= element[j];
    9383         if (value>0.0)
    9384           upValue += value;
    9385         else
    9386           downValue -= value;
    9387       }
    9388     }
    9389     // use dj if bigger
    9390     double dj = cbcReducedCost_[iColumn];
    9391     upValue = CoinMax(upValue,dj);
    9392     downValue = CoinMax(downValue,-dj);
    9393     up[iColumn]=upValue;
    9394     down[iColumn]=downValue;
    9395     if (solver_->isInteger(iColumn)) {
    9396       if (!numberNodes_&&handler_->logLevel()>1)
    9397         printf("%d - dj %g up %g down %g cost %g\n",
    9398                iColumn,dj,upValue,downValue,objective[iColumn]);
    9399       upSum += upValue;
    9400       downSum += downValue;
    9401       numberIntegers++;
    9402     }
    9403   }
     9653        if (value>0.0)
     9654          upValue += value;
     9655        else
     9656          downValue -= value;
     9657      }
     9658      double weight = 0.0;
     9659      for (CoinBigIndex j=start;j<end;j++) {
     9660        int iRow = row[j];
     9661        value = -dual[iRow];
     9662        double thisWeight = rowWeight[iRow];
     9663        if (useAlpha)
     9664          thisWeight *= fabs(element[j]);
     9665        if (!useMax)
     9666          weight += thisWeight;
     9667        else
     9668          weight = CoinMax(weight,thisWeight);
     9669        if (value) {
     9670          value *= element[j];
     9671          if (value>0.0)
     9672            upValue += value;
     9673          else
     9674            downValue -= value;
     9675        }
     9676      }
     9677      columnWeight[iColumn]=weight;
     9678      // use dj if bigger
     9679      double djValue = dj[iColumn];
     9680      upValue = CoinMax(upValue,djValue);
     9681      downValue = CoinMax(downValue,-djValue);
     9682      up[iColumn]=upValue;
     9683      down[iColumn]=downValue;
     9684      if (solver_->isInteger(iColumn)) {
     9685        if (!numberNodes_&&handler_->logLevel()>1)
     9686          printf("%d - dj %g up %g down %g cost %g\n",
     9687                 iColumn,djValue,upValue,downValue,objective[iColumn]);
     9688        upSum += upValue;
     9689        downSum += downValue;
     9690        numberIntegers++;
     9691      }
     9692    }
     9693    if (numberIntegers) {
     9694      double averagePrice=(0.5*(upSum+downSum))/static_cast<double>(numberIntegers);
     9695      //averagePrice *= 0.1;
     9696      averagePrice *= 100.0;
     9697      for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     9698        double weight = columnWeight[iColumn];
     9699        up[iColumn] += averagePrice*weight;
     9700        down[iColumn] += averagePrice*weight;
     9701      }
     9702    }
     9703  }
     9704  delete [] rowWeight;
     9705  delete [] columnWeight;
    94049706  if (numberIntegers) {
    9405     double smallDown = 0.01*(downSum/static_cast<double> (numberIntegers));
    9406     double smallUp = 0.01*(upSum/static_cast<double> (numberIntegers));
     9707    double smallDown = 0.0001*(downSum/static_cast<double> (numberIntegers));
     9708    double smallUp = 0.0001*(upSum/static_cast<double> (numberIntegers));
    94079709    for (int i=0;i<numberObjects_;i++) {
    94089710      CbcSimpleIntegerDynamicPseudoCost * obj1 =
    94099711        dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(object_[i]) ;
    9410       if (obj1) {
    9411         iColumn = obj1->columnNumber();
     9712      if (obj1&&obj1->upShadowPrice()>=0.0) {
     9713        int iColumn = obj1->columnNumber();
    94129714        double upPseudoCost = obj1->upDynamicPseudoCost();
    94139715        double saveUp = upPseudoCost;
    94149716        upPseudoCost = CoinMax(upPseudoCost,smallUp);
    94159717        upPseudoCost = CoinMax(upPseudoCost,up[iColumn]);
    9416         upPseudoCost = CoinMax(upPseudoCost,0.1*down[iColumn]);
    9417         obj1->setUpDynamicPseudoCost(upPseudoCost);
     9718        upPseudoCost = CoinMax(upPseudoCost,0.001*down[iColumn]);
     9719        obj1->setUpShadowPrice(upPseudoCost);
    94189720        if (upPseudoCost>saveUp&&!numberNodes_&&handler_->logLevel()>1)
    94199721          printf("For %d up went from %g to %g\n",
     
    94239725        downPseudoCost = CoinMax(downPseudoCost,smallDown);
    94249726        downPseudoCost = CoinMax(downPseudoCost,down[iColumn]);
    9425         downPseudoCost = CoinMax(downPseudoCost,0.1*down[iColumn]);
    9426         obj1->setDownDynamicPseudoCost(downPseudoCost);
     9727        downPseudoCost = CoinMax(downPseudoCost,0.001*up[iColumn]);
     9728        obj1->setDownShadowPrice(downPseudoCost);
    94279729        if (downPseudoCost>saveDown&&!numberNodes_&&handler_->logLevel()>1)
    94289730          printf("For %d down went from %g to %g\n",
  • trunk/Cbc/src/CbcModel.hpp

    r1223 r1224  
    15701570      17 bit (131072) - Perturbation switched off
    15711571  */
    1572   /// Set special options
    15731572  inline void setSpecialOptions(int value)
    15741573  { specialOptions_=value;}
     
    15791578  inline bool normalSolver() const
    15801579  { return (specialOptions_&16)==0;}
     1580  /** Set more special options
     1581      at present bottom 3 bits used for shadow price mode
     1582  */
     1583  inline void setMoreSpecialOptions(int value)
     1584  { moreSpecialOptions_=value;}
     1585  /// Get more special options
     1586  inline int moreSpecialOptions() const
     1587  { return moreSpecialOptions_;}
    15811588  /// Now we may not own objects - just point to solver's objects
    15821589  inline bool ownObjects() const
     
    18121819  int cliquePseudoCosts(int doStatistics);
    18131820  /// Fill in useful estimates
    1814   void pseudoShadow(double * down, double * up);
     1821  void pseudoShadow(int type);
    18151822  /** Return pseudo costs
    18161823      If not all integers or not pseudo costs - returns all zero
     
    21112118  /// Array marked whenever a solution is found if non-zero
    21122119  int * usedInSolution_;
    2113   /**
     2120  /**
     2121      Special options
    21142122      0 bit (1) - check if cuts valid (if on debugger list)
    21152123      1 bit (2) - use current basis to check integer solution (rather than all slack)
    2116       2 bit (4) - don't check integer solution
    2117       3 bit (8) - Strong is doing well - keep on
     2124      2 bit (4) - don't check integer solution (by solving LP)
     2125      3 bit (8) - fast analyze
     2126      4 bit (16) - non-linear model - so no well defined CoinPackedMatrix
     2127      5 bit (32) - keep names
     2128      6 bit (64) - try for dominated columns
     2129      7 bit (128) - SOS type 1 but all declared integer
     2130      8 bit (256) - Set to say solution just found, unset by doing cuts
     2131      9 bit (512) - Try reduced model after 100 nodes
     2132      10 bit (1024) - Switch on some heuristics even if seems unlikely
     2133      11 bit (2048) - Mark as in small branch and bound
     2134      12 bit (4096) - Funny cuts so do slow way (in some places)
     2135      13 bit (8192) - Funny cuts so do slow way (in other places)
     2136      14 bit (16384) - Use Cplex! for fathoming
     2137      15 bit (32768) - Try reduced model after 0 nodes
     2138      16 bit (65536) - Original model had integer bounds
     2139      17 bit (131072) - Perturbation switched off
    21182140  */
    21192141  int specialOptions_;
     2142  /** More special options
     2143      at present bottom 3 bits used for shadow price mode
     2144  */
     2145  int moreSpecialOptions_;
    21202146  /// User node comparison function
    21212147  CbcCompareBase * nodeCompare_;
  • trunk/Cbc/src/CbcNode.cpp

    r1212 r1224  
    26232623    }
    26242624  }
     2625  /*
     2626    1 strong
     2627    2 no strong
     2628    3 strong just before solution
     2629    4 no strong just before solution
     2630    5 strong first time or before solution
     2631    6 strong first time
     2632  */
     2633  int useShadow = model->moreSpecialOptions()&7;
     2634  if (useShadow>2) {
     2635    if (model->getSolutionCount()) {
     2636      if (numberNodes||useShadow<5) {
     2637        useShadow=0;
     2638        // zap pseudo shadow prices
     2639        model->pseudoShadow(-1);
     2640        // and switch off
     2641        model->setMoreSpecialOptions(model->moreSpecialOptions()&(~1023));
     2642      } else {
     2643        useShadow=1;
     2644      }
     2645    } else if (useShadow<5) {
     2646      useShadow -= 2;
     2647    } else {
     2648      useShadow=1;
     2649    }
     2650  }
     2651  if (useShadow) {
     2652    // pseudo shadow prices
     2653    model->pseudoShadow(model->moreSpecialOptions()>>3);
     2654  }
    26252655#ifdef DEPRECATED_STRATEGY
    26262656  { // in for tabbing
     
    28942924        // may just need resolve
    28952925        model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     2926        //double newObjValue = solver->getObjSense()*solver->getObjValue();
     2927        //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    28962928        if (!solver->isProvenOptimal()) {
    28972929          // infeasible
     
    29302962          solver->setHintParam(OsiDoDualInResolve,false,OsiHintDo) ;
    29312963          model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     2964          //double newObjValue = solver->getObjSense()*solver->getObjValue();
     2965          //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    29322966          solver->setHintParam(OsiDoDualInResolve,takeHint,strength) ;
    29332967          if (!solver->isProvenOptimal()) {
     
    30003034                        model->getDblParam(CbcModel::CbcMaximumSeconds));
    30013035    // also give up if we are looping round too much
    3002     if (hitMaxTime||numberPassesLeft<=0) {
     3036    if (hitMaxTime||numberPassesLeft<=0||useShadow==2) {
    30033037      int iObject = whichObject[bestChoice];
    30043038      OsiObject * object = model->modifiableObject(iObject);
     
    30783112            OsiObject * object = model->modifiableObject(iObject);
    30793113            CbcSimpleIntegerDynamicPseudoCost * dynamicObject =
    3080               static_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ;
     3114              dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ;
    30813115            // Use this object's numberBeforeTrust
    30823116            int numberBeforeTrust = dynamicObject->numberBeforeTrust();
     
    31493183            solver->unmarkHotStart();
    31503184            model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     3185            //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3186            //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    31513187            solver->markHotStart();
    31523188            problemFeasible = solver->isProvenOptimal();
     
    32883324        OsiObject * object = model->modifiableObject(iObject);
    32893325        CbcSimpleIntegerDynamicPseudoCost * dynamicObject =
    3290           static_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ;
     3326          dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ;
    32913327        int iColumn = dynamicObject ? dynamicObject->columnNumber() : numberColumns+iObject;
    32923328        int preferredWay;
     
    32953331        if (!infeasibility)
    32963332          continue;
     3333#ifndef NDEBUG
     3334        if (iColumn<numberColumns) {
     3335            const double * solution = model->testSolution();
     3336            assert (saveSolution[iColumn]==solution[iColumn]);
     3337          }
     3338#endif
    32973339        CbcSimpleInteger * obj =
    32983340          dynamic_cast <CbcSimpleInteger *>(object) ;
     
    34043446              numberStrongInfeasible++;
    34053447            } else {
    3406               // See if integer solution
     3448              //#define TIGHTEN_BOUNDS
     3449#ifdef TIGHTEN_BOUNDS
     3450              // Can we tighten bounds?
     3451              if (iColumn<numberColumns&&cutoff<1.0e20
     3452                  &&objectiveChange>1.0e-5) {
     3453                double value = saveSolution[iColumn];
     3454                double down = value-floor(value);
     3455                double changePer = objectiveChange/(down+1.0e-7);
     3456                double distance = (cutoff-objectiveValue_)/changePer;
     3457                distance += 1.0e-3;
     3458                if (distance<5.0) {
     3459                  double newLower = ceil(value-distance);
     3460                  if (newLower>saveLower[iColumn]) {
     3461                    //printf("Could increase lower bound on %d from %g to %g\n",
     3462                    //   iColumn,saveLower[iColumn],newLower);
     3463                    saveLower[iColumn]=newLower;
     3464                    solver->setColLower(iColumn,newLower);
     3465                  }
     3466                }
     3467                }
     3468#endif
     3469              // See if integer solution
    34073470              if (model->feasibleSolution(choice.numIntInfeasDown,
    34083471                                          choice.numObjInfeasDown)
     
    34183481                  model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    34193482                  newObjectiveValue = solver->getObjSense()*solver->getObjValue();
     3483                  //objectiveValue_ = CoinMax(objectiveValue_,newObjectiveValue);
    34203484                  objectiveChange = CoinMax(newObjectiveValue  - objectiveValue_,0.0);
    34213485                  model->feasibleSolution(choice.numIntInfeasDown,
     
    34513515            needHotStartUpdate = false;
    34523516            model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     3517            //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3518            //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    34533519            //we may again have an integer feasible solution
    34543520            int numberIntegerInfeasibilities;
     
    34683534                                     solver->getColSolution()) ;
    34693535              model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     3536              //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3537              //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    34703538              cutoff =model->getCutoff();
    34713539            }
     
    35223590              numberStrongInfeasible++;
    35233591            } else {
     3592#ifdef TIGHTEN_BOUNDS
     3593              // Can we tighten bounds?
     3594              if (iColumn<numberColumns&&cutoff<1.0e20
     3595                  &&objectiveChange>1.0e-5) {
     3596                double value = saveSolution[iColumn];
     3597                double up = ceil(value)-value;
     3598                double changePer = objectiveChange/(up+1.0e-7);
     3599                double distance = (cutoff-objectiveValue_)/changePer;
     3600                distance += 1.0e-3;
     3601                if (distance<5.0) {
     3602                  double newUpper = floor(value+distance);
     3603                  if (newUpper<saveUpper[iColumn]) {
     3604                    //printf("Could decrease upper bound on %d from %g to %g\n",
     3605                    //   iColumn,saveUpper[iColumn],newUpper);
     3606                    saveUpper[iColumn]=newUpper;
     3607                    solver->setColUpper(iColumn,newUpper);
     3608                  }
     3609                }
     3610                }
     3611#endif
    35243612              // See if integer solution
    35253613              if (model->feasibleSolution(choice.numIntInfeasUp,
     
    35413629                  model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
    35423630                  newObjectiveValue = solver->getObjSense()*solver->getObjValue();
     3631                  //objectiveValue_ = CoinMax(objectiveValue_,newObjectiveValue);
    35433632                  objectiveChange = CoinMax(newObjectiveValue  - objectiveValue_,0.0);
    35443633                  model->feasibleSolution(choice.numIntInfeasDown,
     
    35743663            needHotStartUpdate = false;
    35753664            model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     3665            //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3666            //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    35763667            //we may again have an integer feasible solution
    35773668            int numberIntegerInfeasibilities;
     
    35853676                                     solver->getColSolution()) ;
    35863677              model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     3678              //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3679              //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    35873680              cutoff =model->getCutoff();
    35883681            }
     
    37273820            solver->unmarkHotStart();
    37283821            model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     3822            //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3823            //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    37293824            solver->markHotStart();
    37303825            // may be infeasible (if other way stopped on iterations)
     
    37663861            solver->unmarkHotStart();
    37673862            model->resolve(NULL,11,saveSolution,saveLower,saveUpper);
     3863            //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3864            //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    37683865            solver->markHotStart();
    37693866            // may be infeasible (if other way stopped on iterations)
     
    38483945          solver->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,&easy) ;
    38493946          model->resolve(NULL,11,saveSolution,saveLower,saveUpper) ;
     3947          //double newObjValue = solver->getObjSense()*solver->getObjValue();
     3948          //objectiveValue_ = CoinMax(objectiveValue_,newObjValue);
    38503949          solver->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,NULL) ;
    38513950          feasible = solver->isProvenOptimal();
     
    39704069    usefulInfo.indexRegion_ = NULL;
    39714070    usefulInfo.pi_ = NULL;
     4071  }
     4072  useShadow = model->moreSpecialOptions()&7;
     4073  if ((useShadow==5&&model->getSolutionCount())||useShadow==6) {
     4074    // zap pseudo shadow prices
     4075    model->pseudoShadow(-1);
     4076    // and switch off
     4077    model->setMoreSpecialOptions(model->moreSpecialOptions()&(~1023));
    39724078  }
    39734079  return anyAction;
     
    40954201    OsiObject * object = model->modifiableObject(iObject);
    40964202    CbcSimpleIntegerDynamicPseudoCost * dynamicObject =
    4097       static_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ;
     4203      dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(object) ;
     4204    if (!dynamicObject)
     4205      continue;
    40984206    int iColumn = dynamicObject->columnNumber();
    40994207    int preferredWay;
  • trunk/Cbc/src/CbcSolver.cpp

    r1221 r1224  
    35543554 
    35553555  if (useDIVING>0) {
    3556     int diveOptions=parameters_[whichParam(DIVEOPT,numberParameters_,parameters_)].intValue();
    3557     if (diveOptions<0||diveOptions>10)
     3556    int diveOptions2=parameters_[whichParam(DIVEOPT,numberParameters_,parameters_)].intValue();
     3557    int diveOptions;
     3558    if (diveOptions2>99) {
     3559      // switch on various active set stuff
     3560      diveOptions=diveOptions2%100;
     3561      diveOptions2 -= diveOptions;
     3562      diveOptions2 += 100; // so 0 will be marked
     3563    } else {
     3564      diveOptions=diveOptions2;
     3565      diveOptions2=0;
     3566    }
     3567    if (diveOptions<0||diveOptions>9)
    35583568      diveOptions=2;
    35593569    if ((useDIVING&1)!=0) {
     
    35903600      CbcHeuristicDivePseudoCost heuristicDP(*model);
    35913601      heuristicDP.setHeuristicName("DivePseudoCost");
    3592       heuristicDP.setWhen(diveOptions);
     3602      heuristicDP.setWhen(diveOptions+diveOptions2);
    35933603      model->addHeuristic(&heuristicDP) ;
    35943604    }
     
    70107020                  if (depthMiniBab!=-1)
    70117021                    babModel_->setFastNodeDepth(depthMiniBab);
     7022                }
     7023                int extra4 = parameters_[whichParam(EXTRA4,numberParameters_,parameters_)].intValue();
     7024                if (extra4>=0) {
     7025                  int strategy = extra4%10;
     7026                  extra4 /= 10;
     7027                  int method = extra4 % 100;
     7028                  extra4 /=100;
     7029                  extra4 = strategy + method*8 + extra4*8*32;
     7030                  babModel_->setMoreSpecialOptions(extra4);
    70127031                }
    70137032                int moreMipOptions = parameters_[whichParam(MOREMIPOPTIONS,numberParameters_,parameters_)].intValue();
  • trunk/Cbc/src/CoinSolve.cpp

    r1205 r1224  
    3939#include <cstring>
    4040#include <iostream>
    41 #ifdef CLP_FAST_CODE
    42 // force new style solver
    43 #ifndef NEW_STYLE_SOLVER
    44 #define NEW_STYLE_SOLVER 1
    45 #endif
    46 #else
    47 // Not new style solver
    4841#ifndef NEW_STYLE_SOLVER
    4942#define NEW_STYLE_SOLVER 0
    50 #endif
    5143#endif
    5244#ifdef CBC_OTHER_SOLVER
Note: See TracChangeset for help on using the changeset viewer.