Changeset 1430 for trunk/Clp


Ignore:
Timestamp:
Sep 15, 2009 11:51:17 AM (10 years ago)
Author:
forrest
Message:

changes for fathoming

Location:
trunk/Clp/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpNode.cpp

    r1412 r1430  
    255255  const int * numberUp = stuff->numberUp_;
    256256  const int * numberUpInfeasible = stuff->numberUpInfeasible_;
     257  int numberBeforeTrust = stuff->numberBeforeTrust_;
     258  int stateOfSearch = stuff->stateOfSearch_;
    257259  int iInteger=0;
     260  // weight at 1.0 is max min (CbcBranch was 0.8,0.1) (ClpNode was 0.9,0.9)
     261#define WEIGHT_AFTER 0.9
     262#define WEIGHT_BEFORE 0.2
     263  //Stolen from Constraint Integer Programming book (with epsilon change)
     264#define WEIGHT_PRODUCT
     265#ifdef WEIGHT_PRODUCT
     266  double smallChange = stuff->smallChange_;
     267#endif
    258268  for (iColumn=0;iColumn<numberColumns;iColumn++) {
    259269    if (integerType[iColumn]) {
     
    295305        }
    296306        //assert (fabs(dj2)<1.0e-4);
    297         double upValue2 = (upPseudo[iInteger]/(1.0+numberUp[iInteger]));
     307        int nUp=numberUp[iInteger];
     308        double upValue2 = (upPseudo[iInteger]/(1.0+nUp));
    298309        // Extra for infeasible branches
    299         if (numberUp[iInteger]) {
     310        if (nUp) {
    300311          double ratio = 1.0+static_cast<double>(numberUpInfeasible[iInteger])/
    301             static_cast<double>(numberUp[iInteger]);
     312            static_cast<double>(nUp);
    302313          upValue2 *= ratio;
    303314        }
    304         double downValue2 = (downPseudo[iInteger]/(1.0+numberDown[iInteger]));
    305         if (numberDown[iInteger]) {
     315        int nDown = numberDown[iInteger];
     316        double downValue2 = (downPseudo[iInteger]/(1.0+nDown));
     317        if (nDown) {
    306318          double ratio = 1.0+static_cast<double>(numberDownInfeasible[iInteger])/
    307             static_cast<double>(numberDown[iInteger]);
     319            static_cast<double>(nDown);
    308320          downValue2 *= ratio;
    309321        }
     
    317329        downValue *= value-floor(value);
    318330        double infeasibility;
    319         if (depth>1000)
    320           infeasibility = CoinMax(upValue,downValue)+integerTolerance;
    321         else
    322           infeasibility = 0.1*CoinMax(upValue,downValue)+
    323             0.9*CoinMin(upValue,downValue) + integerTolerance;
     331        //if (depth>1000)
     332        //infeasibility = CoinMax(upValue,downValue)+integerTolerance;
     333        //else
     334        if (stateOfSearch<=2) {
     335          // no solution
     336          infeasibility = (1.0-WEIGHT_BEFORE)*CoinMax(upValue,downValue)+
     337            WEIGHT_BEFORE*CoinMin(upValue,downValue) + integerTolerance;
     338        } else {
     339#ifndef WEIGHT_PRODUCT
     340          infeasibility = (1.0-WEIGHT_AFTER)*CoinMax(upValue,downValue)+
     341            WEIGHT_AFTER*CoinMin(upValue,downValue) + integerTolerance;
     342#else
     343          infeasibility = CoinMax(CoinMax(upValue,downValue),smallChange)*
     344            CoinMax(CoinMin(upValue,downValue),smallChange);
     345#endif
     346        }
    324347        estimatedSolution_ += CoinMin(upValue2,downValue2);
    325348#elif PSEUDO==3
     349        int nUp=numberUp[iInteger];
     350        int nDown = numberDown[iInteger];
    326351        // Extra 100% for infeasible branches
    327352        double upValue = (ceil(value)-value)*(upPseudo[iInteger]/
    328                                               (1.0+numberUp[iInteger]));
    329         if (numberUp[iInteger]) {
     353                                              (1.0+nUp));
     354        if (nUp) {
    330355          double ratio = 1.0+static_cast<double>(numberUpInfeasible[iInteger])/
    331             static_cast<double>(numberUp[iInteger]);
     356            static_cast<double>(nUp);
    332357          upValue *= ratio;
    333358        }
    334359        double downValue = (value-floor(value))*(downPseudo[iInteger]/
    335                                                  (1.0+numberDown[iInteger]));
    336         if (numberDown[iInteger]) {
     360                                                 (1.0+nDown));
     361        if (nDown) {
    337362          double ratio = 1.0+static_cast<double>(numberDownInfeasible[iInteger])/
    338             static_cast<double>(numberDown[iInteger]);
     363            static_cast<double>(nDown);
    339364          downValue *= ratio;
    340365        }
     366        if (nUp<numberBeforeTrust||nDown<numberBeforeTrust) {
     367          upValue *= 10.0;
     368          downValue *= 10.0;
     369        }
     370         
    341371        double infeasibility;
    342         if (depth>1000)
    343           infeasibility = CoinMax(upValue,downValue)+integerTolerance;
    344         else
    345           infeasibility = 0.1*CoinMax(upValue,downValue)+
    346             0.9*CoinMin(upValue,downValue) + integerTolerance;
     372        //if (depth>1000)
     373        //infeasibility = CoinMax(upValue,downValue)+integerTolerance;
     374        //else
     375        if (stateOfSearch<=2) {
     376          // no solution
     377          infeasibility = (1.0-WEIGHT_BEFORE)*CoinMax(upValue,downValue)+
     378            WEIGHT_BEFORE*CoinMin(upValue,downValue) + integerTolerance;
     379        } else {
     380#ifndef WEIGHT_PRODUCT
     381          infeasibility = (1.0-WEIGHT_AFTER)*CoinMax(upValue,downValue)+
     382            WEIGHT_AFTER*CoinMin(upValue,downValue) + integerTolerance;
     383#else
     384          infeasibility = CoinMax(CoinMax(upValue,downValue),smallChange)*
     385            CoinMax(CoinMin(upValue,downValue),smallChange);
     386          //infeasibility += CoinMin(upValue,downValue)*smallChange;
     387#endif
     388        }
     389        //infeasibility = 0.1*CoinMax(upValue,downValue)+
     390        //0.9*CoinMin(upValue,downValue) + integerTolerance;
    347391        estimatedSolution_ += CoinMin(upValue,downValue);
    348392#else
     
    653697  integerTolerance_(1.0e-7),
    654698  integerIncrement_(1.0e-8),
     699  smallChange_(1.0e-8),
    655700  downPseudo_(NULL),
    656701  upPseudo_(NULL),
     
    669714  solverOptions_(0),
    670715  maximumNodes_(0),
     716  numberBeforeTrust_(0),
     717  stateOfSearch_(0),
    671718  nDepth_(-1),
    672719  nNodes_(0),
     
    684731  : integerTolerance_(rhs.integerTolerance_),
    685732    integerIncrement_(rhs.integerIncrement_),
     733    smallChange_(rhs.smallChange_),
    686734    downPseudo_(NULL),
    687735    upPseudo_(NULL),
     
    700748    solverOptions_(rhs.solverOptions_),
    701749    maximumNodes_(rhs.maximumNodes_),
     750    numberBeforeTrust_(rhs.numberBeforeTrust_),
     751    stateOfSearch_(rhs.stateOfSearch_),
    702752    nDepth_(rhs.nDepth_),
    703753    nNodes_(rhs.nNodes_),
     
    716766    integerTolerance_ = rhs.integerTolerance_;
    717767    integerIncrement_ = rhs.integerIncrement_;
     768    smallChange_ = rhs.smallChange_;
    718769    downPseudo_ = NULL;
    719770    upPseudo_ = NULL;
     
    732783    solverOptions_ = rhs.solverOptions_;
    733784    maximumNodes_ = rhs.maximumNodes_;
     785    numberBeforeTrust_ = rhs.numberBeforeTrust_;
     786    stateOfSearch_ = rhs.stateOfSearch_;
    734787    int n = maximumNodes();
    735788    if (n) {
     
    770823    solverOptions_ = 0;
    771824    maximumNodes_ = 0;
     825    numberBeforeTrust_ = 0;
     826    stateOfSearch_ = 0;
    772827    nDepth_ = -1;
    773828    nNodes_ = 0;
  • trunk/Clp/src/ClpNode.hpp

    r1412 r1430  
    205205  /// Integer increment
    206206  double integerIncrement_;
     207  /// Small chnage in branch
     208  double smallChange_;
    207209  /// Down pseudo costs
    208210  double * downPseudo_;
     
    244246  /// Maximum number of nodes to do
    245247  int maximumNodes_;
     248  /// Number before trust from CbcModel
     249  int numberBeforeTrust_;
     250  /// State of search from CbcModel
     251  int stateOfSearch_;
    246252  /// Number deep
    247253  int nDepth_;
Note: See TracChangeset for help on using the changeset viewer.