Changeset 1088


Ignore:
Timestamp:
Oct 8, 2008 4:24:17 AM (11 years ago)
Author:
forrest
Message:

changes for event handler and problems with few costs

Location:
trunk/Cbc/src
Files:
13 edited

Legend:

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

    r1087 r1088  
    12301230  value = CoinMin(value, info->upper_[columnNumber_]);
    12311231  assert (info->upper_[columnNumber_]>info->lower_[columnNumber_]);
    1232   if (!info->hotstartSolution_) {
     1232  if (!info->hotstartSolution_&&priority_!=-999) {
    12331233#ifndef NDEBUG
    12341234    double nearest = floor(value+0.5);
    12351235    assert (fabs(value-nearest)>info->integerTolerance_);
    12361236#endif
    1237   } else {
     1237  } else if (info->hotstartSolution_) {
    12381238    double targetValue = info->hotstartSolution_[columnNumber_];
    12391239    if (way>0)
     
    12411241    else
    12421242      value = targetValue+0.1;
    1243   }
     1243  } else {
     1244    if (value<=info->lower_[columnNumber_])
     1245      value += 0.1;
     1246    else if (value>=info->upper_[columnNumber_])
     1247      value -= 0.1;
     1248  }
     1249  assert (value>=info->lower_[columnNumber_]&&
     1250          value<=info->upper_[columnNumber_]);
    12441251  branch->fillPart(columnNumber_,way,value);
    12451252}
  • trunk/Cbc/src/CbcBranchDynamic.cpp

    r1087 r1088  
    713713#define WEIGHT_BEFORE 0.1
    714714  if (fabs(value-nearest)<=integerTolerance) {
    715     return 0.0;
     715    if (priority_!=-999)
     716      return 0.0;
     717    else
     718      return 1.0e-13;
    716719  } else {
    717720#ifdef CBC_INSTRUMENT
     
    929932  value = CoinMin(value, info->upper_[columnNumber_]);
    930933  assert (info->upper_[columnNumber_]>info->lower_[columnNumber_]);
    931   if (!info->hotstartSolution_) {
     934  if (!info->hotstartSolution_&&priority_!=-999) {
    932935#ifndef NDEBUG
    933936    double nearest = floor(value+0.5);
    934937    assert (fabs(value-nearest)>info->integerTolerance_);
    935938#endif
    936   } else {
     939  } else if (info->hotstartSolution_) {
    937940    double targetValue = info->hotstartSolution_[columnNumber_];
    938941    if (way>0)
     
    940943    else
    941944      value = targetValue+0.1;
    942   }
     945  } else {
     946    if (value<=info->lower_[columnNumber_])
     947      value += 0.1;
     948    else if (value>=info->upper_[columnNumber_])
     949      value -= 0.1;
     950  }
     951  assert (value>=info->lower_[columnNumber_]&&
     952          value<=info->upper_[columnNumber_]);
    943953  CbcDynamicPseudoCostBranchingObject * newObject =
    944954    new CbcDynamicPseudoCostBranchingObject(model_,columnNumber_,way,
  • trunk/Cbc/src/CbcCountRowCut.cpp

    r1000 r1088  
    88
    99#include "OsiRowCut.hpp"
     10#include "CbcModel.hpp"
    1011#include "CbcCountRowCut.hpp"
    1112#include "CbcNode.hpp"
  • trunk/Cbc/src/CbcHeuristic.cpp

    r1087 r1088  
    527527  char * reset = NULL;
    528528  int returnCode=1;
     529  int saveModelOptions = model_->specialOptions();
     530  assert ((saveModelOptions&2048)==0);
     531  model_->setSpecialOptions(saveModelOptions|2048);
    529532  {
    530533    int saveLogLevel = solver->messageHandler()->logLevel();
     
    544547    delete pinfo;
    545548    // see if too big
     549   
    546550    if (presolvedModel) {
    547551      int afterRows = presolvedModel->getNumRows();
     
    605609                      solver->getNumRows(),solver->getNumCols(),
    606610                      afterRows,afterCols,nFix,afterRows2,afterCols2);
     611              // If much too big - give up
     612              if (after>0.75*before)
     613                returnCode=-1;
    607614            } else {
    608615              sprintf(generalPrint,"Full problem %d rows %d columns, reduced to %d rows %d columns - %d fixed gives %d, %d - ok now",
     
    610617                      afterRows,afterCols,nFix,afterRows2,afterCols2);
    611618            }
    612             model_->messageHandler()->message(CBC_FPUMP1,model_->messages())
     619            model_->messageHandler()->message(CBC_GENERAL,model_->messages())
    613620              << generalPrint
    614621              <<CoinMessageEol;
     
    623630    solver->messageHandler()->setLogLevel(saveLogLevel);
    624631  }
    625   if (returnCode==2) {
     632  if (returnCode==2||returnCode==-1) {
     633    model_->setSpecialOptions(saveModelOptions);
    626634    delete [] reset;
    627635#ifdef HISTORY_STATISTICS
     
    687695        if (numberNodes>=0) {
    688696          // normal
     697          model_->setSpecialOptions(saveModelOptions|2048);
    689698          if (logLevel<=1)
    690699            model.setLogLevel(0);
     
    703712          model.setMaximumCutPasses(CoinMin(10,model_->getMaximumCutPasses()));
    704713        } else {
     714          model_->setSpecialOptions(saveModelOptions);
    705715          model_->messageHandler()->message(CBC_RESTART,model_->messages())
    706716            <<solver2->getNumRows()<<solver2->getNumCols()
     
    775785            <<CoinMessageEol;
    776786        // probably faster to use a basis to get integer solutions
    777         model.setSpecialOptions(2);
     787        model.setSpecialOptions(model.specialOptions()|2);
    778788#ifdef CBC_THREAD
    779789        if (model_->getNumberThreads()>0&&(model_->getThreadMode()&1)!=0) {
     
    963973    returnCode=2; // infeasible finished
    964974  }
     975  model_->setSpecialOptions(saveModelOptions);
    965976  model_->setLogLevel(logLevel);
    966977  if (reset) {
  • trunk/Cbc/src/CbcHeuristicDive.cpp

    r1040 r1088  
    451451    }
    452452    int originalBestRound = bestRound;
     453    int saveModelOptions = model_->specialOptions();
    453454    while (1) {
    454455
     456      model_->setSpecialOptions(saveModelOptions|2048);
    455457      solver->resolve();
     458      model_->setSpecialOptions(saveModelOptions);
    456459
    457460      if(!solver->isProvenOptimal()) {
     
    516519      printf("switching off diving as too many iterations %d, %d allowed\n",
    517520             numberSimplexIterations,maxSimplexIterations);
     521#endif
     522      when_=0;
     523      break;
     524    }
     525
     526    if (solver->getIterationCount()>1000&&iteration>3) {
     527#ifdef DIVE_DEBUG
     528      reasonToStop = 5;
     529#endif
     530      // also switch off
     531#ifdef CLP_INVESTIGATE
     532      printf("switching off diving one iteration took %d iterations (total %d)\n",
     533             solver->getIterationCount(),numberSimplexIterations);
    518534#endif
    519535      when_=0;
  • trunk/Cbc/src/CbcHeuristicFPump.cpp

    r1067 r1088  
    1212#include "OsiSolverInterface.hpp"
    1313#include "CbcModel.hpp"
     14#ifdef COIN_HAS_CLP
     15#include "OsiClpSolverInterface.hpp"
     16#endif
    1417#include "CbcMessage.hpp"
    1518#include "CbcHeuristicFPump.hpp"
     
    1922#include "CoinTime.hpp"
    2023#include "CbcEventHandler.hpp"
    21 #ifdef COIN_HAS_CLP
    22 #include "OsiClpSolverInterface.hpp"
    23 #endif
    2424
    2525
     
    229229    iterationLimit = (2*model_->solver()->getNumRows()+2*numberColumns)*
    230230      iterationRatio_;
    231   double totalNumberIterations=0.0;
     231  int totalNumberIterations=0;
     232  int numberIterationsPass1=-1;
     233  int numberIterationsLastPass=0;
    232234  // 1. initially check 0-1
    233235  int i,j;
     
    525527            usedColumn[i]=numberPasses;
    526528          lastSolution[i]=solution[i];
     529        }
     530      }
     531      if (numberIterationsPass1>=0) {
     532        int n = totalNumberIterations - numberIterationsLastPass;
     533        if (n>CoinMax(15000,3*numberIterationsPass1)) {
     534          exitAll=true;
     535          break;
    527536        }
    528537      }
     
    979988                delete basis;
    980989              }
     990              delete [] firstPerturbedObjective;
     991              delete [] firstPerturbedSolution;
    981992              firstPerturbedObjective = CoinCopyOfArray(solver->getObjCoefficients(),numberColumns);
    982993              firstPerturbedSolution = CoinCopyOfArray(solver->getColSolution(),numberColumns);
     
    16031614          usedColumn[i]=-1;
    16041615      }
     1616      if (!totalNumberPasses)
     1617        numberIterationsPass1 = totalNumberIterations;
     1618      numberIterationsLastPass =  totalNumberIterations;
    16051619      totalNumberPasses += numberPasses-1;
    16061620    }
     
    16771691    double ncol = model_->solver()->getNumCols();
    16781692    double nrow = model_->solver()->getNumRows();
    1679     printf("XXX total iterations %g ratios - %g %g %g\n",
     1693    printf("XXX total iterations %d ratios - %g %g %g\n",
    16801694           totalNumberIterations,
    1681            totalNumberIterations/nrow,
    1682            totalNumberIterations/ncol,
    1683            totalNumberIterations/(2*nrow+2*ncol));
     1695           ((double) totalNumberIterations)/nrow,
     1696           ((double) totalNumberIterations)/ncol,
     1697           ((double) totalNumberIterations)/(2*nrow+2*ncol));
    16841698  }
    16851699#endif
     
    19721986}
    19731987
     1988# ifdef COIN_HAS_CLP
    19741989 
     1990//#############################################################################
     1991// Constructors / Destructor / Assignment
     1992//#############################################################################
     1993
     1994//-------------------------------------------------------------------
     1995// Default Constructor
     1996//-------------------------------------------------------------------
     1997CbcDisasterHandler::CbcDisasterHandler (CbcModel * model)
     1998  : OsiClpDisasterHandler(),
     1999    cbcModel_(model)
     2000{
     2001  if (model) {
     2002    osiModel_
     2003      = dynamic_cast<OsiClpSolverInterface *> (model->solver());
     2004    if (osiModel_)
     2005      setSimplex(osiModel_->getModelPtr());
     2006  }
     2007}
     2008
     2009//-------------------------------------------------------------------
     2010// Copy constructor
     2011//-------------------------------------------------------------------
     2012CbcDisasterHandler::CbcDisasterHandler (const CbcDisasterHandler & rhs)
     2013  : OsiClpDisasterHandler(rhs),
     2014    cbcModel_(rhs.cbcModel_)
     2015
     2016}
     2017
     2018
     2019//-------------------------------------------------------------------
     2020// Destructor
     2021//-------------------------------------------------------------------
     2022CbcDisasterHandler::~CbcDisasterHandler ()
     2023{
     2024}
     2025
     2026//----------------------------------------------------------------
     2027// Assignment operator
     2028//-------------------------------------------------------------------
     2029CbcDisasterHandler &
     2030CbcDisasterHandler::operator=(const CbcDisasterHandler& rhs)
     2031{
     2032  if (this != &rhs) {
     2033    OsiClpDisasterHandler::operator=(rhs);
     2034    cbcModel_ = rhs.cbcModel_;
     2035  }
     2036  return *this;
     2037}
     2038//-------------------------------------------------------------------
     2039// Clone
     2040//-------------------------------------------------------------------
     2041ClpDisasterHandler * CbcDisasterHandler::clone() const
     2042{
     2043  return new CbcDisasterHandler(*this);
     2044}
     2045// Type of disaster 0 can fix, 1 abort
     2046int
     2047CbcDisasterHandler::typeOfDisaster()
     2048{
     2049  if (!cbcModel_->parentModel()&
     2050      (cbcModel_->specialOptions()&2048)==0) {
     2051    return 0;
     2052  } else {
     2053    if (cbcModel_->parentModel())
     2054      cbcModel_->setMaximumNodes(0);
     2055    return 1;
     2056  }
     2057}
     2058/* set model. */
     2059void
     2060CbcDisasterHandler::setCbcModel(CbcModel * model)
     2061{
     2062  cbcModel_ = model;
     2063  if (model) {
     2064    osiModel_
     2065      = dynamic_cast<OsiClpSolverInterface *> (model->solver());
     2066    if (osiModel_)
     2067      setSimplex(osiModel_->getModelPtr());
     2068    else
     2069      setSimplex(NULL);
     2070  }
     2071}
     2072#endif
     2073 
  • trunk/Cbc/src/CbcHeuristicFPump.hpp

    r1053 r1088  
    208208};
    209209
    210 
     210# ifdef COIN_HAS_CLP
     211 
     212class CbcDisasterHandler : public OsiClpDisasterHandler {
     213public:
     214  /**@name Virtual methods that the derived classe should provide.
     215  */
     216  //@{
     217#if 0
     218  /// Into simplex
     219  virtual void intoSimplex();
     220  /// Checks if disaster
     221  virtual bool check() const ;
     222  /// saves information for next attempt
     223  virtual void saveInfo();
    211224#endif
     225  /// Type of disaster 0 can fix, 1 abort
     226  virtual int typeOfDisaster();
     227  //@}
     228 
     229 
     230  /**@name Constructors, destructor */
     231
     232  //@{
     233  /** Default constructor. */
     234  CbcDisasterHandler(CbcModel * model = NULL);
     235  /** Destructor */
     236  virtual ~CbcDisasterHandler();
     237  // Copy
     238  CbcDisasterHandler(const CbcDisasterHandler&);
     239  // Assignment
     240  CbcDisasterHandler& operator=(const CbcDisasterHandler&);
     241  /// Clone
     242  virtual ClpDisasterHandler * clone() const;
     243
     244  //@}
     245 
     246  /**@name Sets/gets */
     247
     248  //@{
     249  /** set model. */
     250  void setCbcModel(CbcModel * model);
     251  /// Get model
     252  inline CbcModel * cbcModel() const
     253  { return cbcModel_;}
     254 
     255  //@}
     256 
     257 
     258protected:
     259  /**@name Data members
     260     The data members are protected to allow access for derived classes. */
     261  //@{
     262  /// Pointer to model
     263  CbcModel * cbcModel_;
     264     
     265  //@}
     266};
     267#endif
     268
     269#endif
  • trunk/Cbc/src/CbcMessage.cpp

    r954 r1088  
    6464  {CBC_RELAXED2,43,1,"Possible objective of %.18g but variables are up to %g away from bound (within tolerance of %g) - might be able to fudge solution - but do you want to?"},
    6565  {CBC_RESTART,44,1,"Reduced cost fixing - %d rows, %d columns - restarting search"},
     66  {CBC_GENERAL,45,1,"%s"},
    6667  {CBC_DUMMY_END,999999,0,""}
    6768};
  • trunk/Cbc/src/CbcMessage.hpp

    r954 r1088  
    6868  CBC_RELAXED2,
    6969  CBC_RESTART,
     70  CBC_GENERAL,
    7071  CBC_DUMMY_END
    7172};
  • trunk/Cbc/src/CbcModel.cpp

    r1087 r1088  
    467467    const CoinBigIndex * columnStart = solver_->getMatrixByCol()->getVectorStarts();
    468468    const int * columnLength = solver_->getMatrixByCol()->getVectorLengths();
     469    int numberInteger=0;
     470    int numberIntegerObj=0;
     471    int numberContinuousObj=0;
     472    double cost=COIN_DBL_MAX;
    469473    for (iColumn=0;iColumn<numberColumns;iColumn++) {
    470474      if (upper[iColumn]==lower[iColumn]) {
     
    475479          rhs[iRow] += lower[iColumn]*element[j];
    476480        }
    477       }
     481      } else {
     482        double objValue = objective[iColumn];
     483        if(solver_->isInteger(iColumn))
     484          numberInteger++;
     485        if (objValue) {
     486          if(!solver_->isInteger(iColumn)) {
     487            numberContinuousObj++;
     488          } else {
     489            numberIntegerObj++;
     490            if (cost==COIN_DBL_MAX)
     491              cost = objValue;
     492            else if (cost!=objValue)
     493              cost=-COIN_DBL_MAX;
     494          }
     495        }
     496      }
     497    }
     498    int iType=0;
     499    if (!numberContinuousObj&&numberIntegerObj<=5&&
     500        numberIntegerObj*3<numberObjects_&&!parentModel_&&solver_->getNumRows()>100)
     501      iType=3;
     502    else if (!numberContinuousObj&&numberIntegerObj<=100&&
     503        numberIntegerObj*5<numberObjects_&&!parentModel_&&
     504             solver_->getNumRows()>100&&cost!=-COIN_DBL_MAX)
     505      iType=2;
     506    //else if (!numberContinuousObj&&
     507    //numberIntegerObj*20<numberObjects_&&!parentModel_&&
     508    //     solver_->getNumRows()>100)
     509    //iType=8;
     510    int iTest =getMaximumNodes();
     511    if (iTest>=987654320&&iTest<987654330&&numberObjects_&&!parentModel_) {
     512      iType = iTest-987654320;
     513      printf("Testing %d integer variables out of %d objects (%d integer) have cost of %g - %d continuous\n",
     514             numberIntegerObj,numberObjects_,numberInteger,cost,numberContinuousObj);
     515      if (iType==9)
     516        exit(77);
     517      if (numberContinuousObj)
     518        iType=0;
     519    }
     520       
     521    //if (!numberContinuousObj&&(numberIntegerObj<=5||cost!=-COIN_DBL_MAX)&&
     522    //numberIntegerObj*3<numberObjects_&&!parentModel_&&solver_->getNumRows()>100) {
     523    if (iType) {
     524      /*
     525        A) put high priority on (if none)
     526        B) create artificial objective (if clp)
     527      */
     528      int iPriority=-1;
     529      for (int i=0;i<numberObjects_;i++) {
     530        int k = object_[i]->priority();
     531        if (iPriority==-1)
     532          iPriority=k;
     533        else if (iPriority!=k)
     534          iPriority=-2;
     535      }
     536      bool branchOnSatisfied=((iType&1)!=0);
     537      bool createFake=((iType&2)!=0);
     538      bool randomCost=((iType&4)!=0);
     539      if (iPriority>=0) {
     540        char general[200];
     541        if (cost==-COIN_DBL_MAX)
     542          sprintf(general,"%d integer variables out of %d objects (%d integer) have costs - high priority",
     543                  numberIntegerObj,numberObjects_,numberInteger);
     544        else
     545          sprintf(general,"%d integer variables out of %d objects (%d integer) have cost of %g - high priority",
     546                  numberIntegerObj,numberObjects_,numberInteger,cost);
     547        messageHandler()->message(CBC_GENERAL,
     548                                  messages())
     549          << general << CoinMessageEol ;
     550        sprintf(general,"branch on satisfied %c create fake objective %c random cost %c",
     551               branchOnSatisfied ? 'Y' :'N',
     552               createFake ? 'Y' :'N',
     553               randomCost ? 'Y' :'N');
     554        messageHandler()->message(CBC_GENERAL,
     555                                  messages())
     556          << general << CoinMessageEol ;
     557        // switch off clp type branching
     558        fastNodeDepth_ = -1;
     559        int highPriority = (branchOnSatisfied) ? -999 : 100;
     560        for (int i=0;i<numberObjects_;i++) {
     561          CbcSimpleInteger * thisOne = dynamic_cast <CbcSimpleInteger *> (object_[i]);
     562          object_[i]->setPriority(1000);
     563          if (thisOne) {
     564            int iColumn = thisOne->columnNumber();
     565            if (objective[iColumn])
     566              thisOne->setPriority(highPriority);
     567          }
     568        }
     569      }
     570#ifdef COIN_HAS_CLP
     571      OsiClpSolverInterface * clpSolver
     572        = dynamic_cast<OsiClpSolverInterface *> (solver_);
     573      if (clpSolver&&createFake) {
     574        // Create artificial objective to be used when all else fixed
     575        int numberColumns = clpSolver->getNumCols();
     576        double * fakeObj = new double [numberColumns];
     577        // Column copy
     578        const CoinPackedMatrix  * matrixByCol = clpSolver->getMatrixByCol();
     579        //const double * element = matrixByCol.getElements();
     580        //const int * row = matrixByCol.getIndices();
     581        //const CoinBigIndex * columnStart = matrixByCol.getVectorStarts();
     582        const int * columnLength = matrixByCol->getVectorLengths();
     583        for (int i=0;i<numberColumns;i++) {
     584          double lowerValue=lower[i];
     585          double upperValue=upper[i];
     586          double value = (randomCost) ? ceil((CoinDrand48()+0.5)*1000)
     587            : i+1;
     588          value *= 0.001;
     589          value += columnLength[i];
     590          if (lowerValue>-1.0e5||upperValue<1.0e5) {
     591            if (fabs(lowerValue)>fabs(upperValue))
     592              value = - value;
     593          } else {
     594            value=0.0;
     595          }
     596          if (clpSolver->isInteger(i))
     597            value *= 100;
     598          fakeObj[i]=value;
     599        }
     600        // pass to solver
     601        clpSolver->setFakeObjective(fakeObj);
     602        delete [] fakeObj;
     603      }
     604#endif
    478605    }
    479606    int iRow;
     
    9381065     = dynamic_cast<OsiClpSolverInterface *> (solver_);
    9391066   if (clpSolver) {
     1067     // pass in disaster handler
     1068     CbcDisasterHandler handler(this);
     1069     clpSolver->passInDisasterHandler(&handler);
    9401070     // Initialise solvers seed
    9411071     clpSolver->getModelPtr()->setRandomSeed(1234567);
     
    35673697          int newNumber = (int) (defaultParallelNodes * scaleFactor+0.5001);
    35683698          if (newNumber*2<defaultParallelIterations) {
    3569             printf("Changing tree size from %d to %d\n",
     3699            char general[200];
     3700            sprintf(general,"Changing tree size from %d to %d",
    35703701                   defaultParallelNodes,newNumber);
     3702            messageHandler()->message(CBC_GENERAL,
     3703                                      messages())
     3704              << general << CoinMessageEol ;
    35713705            defaultParallelNodes = newNumber;
    35723706          }
     
    40804214    }
    40814215  }
     4216#ifdef COIN_HAS_CLP
     4217  {
     4218    OsiClpSolverInterface * clpSolver
     4219      = dynamic_cast<OsiClpSolverInterface *> (solver_);
     4220    if (clpSolver)
     4221      clpSolver->setFakeObjective((double *) NULL);
     4222  }
     4223#endif
    40824224#ifdef CLP_QUICK_OPTIONS
    40834225  {
     
    78738015      if (whenC==999999|whenC==999998) {
    78748016        int size = continuousSolver_->getNumRows()+continuousSolver_->getNumCols();
    7875         bool small = size<=550;
    7876         small=false;
     8017        bool smallProblem = size<=550;
     8018        smallProblem=false;
    78778019#ifdef CLP_INVESTIGATE
    78788020        int maxPass=maximumCutPasses_;
     
    78838025            if (whenCuts_==999999) {
    78848026              whenCuts_=5000010;
    7885               if (!small)
     8027              if (!smallProblem)
    78868028                maximumCutPasses_=CoinMax(maximumCutPasses_>>1,1);
    78878029            } else if (whenCuts_==999998) {
    78888030              whenCuts_=5000010;
    7889               if (!small)
     8031              if (!smallProblem)
    78908032                maximumCutPasses_=CoinMax(maximumCutPasses_>>1,1);
    78918033            }
     
    79198061            if (whenCuts_==999999) {
    79208062              whenCuts_=8000008;
    7921               if (!small)
     8063              if (!smallProblem)
    79228064                maximumCutPasses_=CoinMax(maximumCutPasses_>>1,1);
    79238065            } else if (whenCuts_==999998) {
    79248066              whenCuts_=10000004;
    7925               if (!small)
     8067              if (!smallProblem)
    79268068                maximumCutPasses_=CoinMax(maximumCutPasses_>>1,1);
    79278069            }
     
    79518093            if (whenCuts_==999999) {
    79528094              whenCuts_=8000008;
    7953               if (!small)
     8095              if (!smallProblem)
    79548096                maximumCutPasses_=CoinMax(maximumCutPasses_>>1,1);
    79558097            } else if (whenCuts_==999998) {
    79568098              whenCuts_=10000004;
    7957               if (!small)
     8099              if (!smallProblem)
    79588100                maximumCutPasses_=CoinMax(maximumCutPasses_>>1,1);
    79598101            }
     
    80398181    }
    80408182    int iProbing=-1;
    8041     double small = (0.2* totalCuts) /
     8183    double smallProblem = (0.2* totalCuts) /
    80428184      ((double) numberActiveGenerators) ;
    80438185    for (i = 0;i<numberCutGenerators_;i++) {
     
    80898231              howOften = 1000000+SCANCUTS; // wait until next time
    80908232#endif
    8091           } else if (thisCuts<small) {
     8233          } else if (thisCuts<smallProblem) {
    80928234            if (howOften!=1&&!probingWasOnBut) {
    80938235              if (generator_[i]->whatDepth()<0||howOften!=-1) {
    8094                 int k = (int) sqrt(small/thisCuts) ;
     8236                int k = (int) sqrt(smallProblem/thisCuts) ;
    80958237                if (howOften!=-98)
    80968238                  howOften = k+1000000 ;
     
    1254012682            new CbcOneGeneralBranchingObject(this,generalBranch,i);
    1254112683          newNode2->setBranchingObject(object);
     12684          assert (lastws->fullBasis());
    1254212685          newNode2->createInfo(this,oldNode,lastws,
    1254312686                               lowerBefore,upperBefore,
     
    1256012703        newNode = newNode2;
    1256112704      } else {
     12705        if (lastws) {
     12706#ifdef CBC_DETERMINISTIC_THREAD
     12707          lastws->fixFullBasis();
     12708#else
     12709          assert (lastws->fullBasis());
     12710#endif
     12711        }
    1256212712        newNode->createInfo(this,oldNode,lastws,lowerBefore,upperBefore,
    1256312713                            numberOldActiveCuts_,numberNewCuts_) ;
     
    1288713037    if (numberAway) {
    1288813038      sprintf(printBuffer,"Warning %d integer variables were more than 1.0e-4 away from integer",numberAway);
    12889       messageHandler()->message(CBC_FPUMP1,messages())
     13039      messageHandler()->message(CBC_GENERAL,messages())
    1289013040        << printBuffer << CoinMessageEol ;
    1289113041    }
     
    1289713047        sprintf(printBuffer,"Given objective value %g, computed %g",
    1289813048                objectiveValue,objValue);
    12899         messageHandler()->message(CBC_FPUMP1,messages())
     13049        messageHandler()->message(CBC_GENERAL,messages())
    1290013050          << printBuffer << CoinMessageEol ;
    1290113051      }
     
    1292013070    // Return if no good
    1292113071    if (!looksGood) {
    12922       messageHandler()->message(CBC_FPUMP1,messages())
     13072      messageHandler()->message(CBC_GENERAL,messages())
    1292313073        << "Error solution not saved as not feasible" << CoinMessageEol ;
    1292413074      return;
     
    1292713077      sprintf(printBuffer,"Solution with objective value %g saved",
    1292813078              objectiveValue);
    12929       messageHandler()->message(CBC_FPUMP1,messages())
     13079      messageHandler()->message(CBC_GENERAL,messages())
    1293013080        << printBuffer << CoinMessageEol ;
    1293113081      // may be able to change cutoff now
     
    1297013120   
    1297113121    currentPassNumber_ = 1; // so root heuristics will run
     13122    // Modify based on size etc
     13123    adjustHeuristics();
    1297213124    for (i = 0;i<numberHeuristics_;i++) {
    1297313125#if MODEL3
     
    1523415386  return doCuts;
    1523515387}
     15388#include "CbcHeuristicDive.hpp"
     15389// Adjust heuristics based on model
     15390void
     15391CbcModel::adjustHeuristics()
     15392{
     15393  int numberRows = solver_->getNumRows();
     15394  int numberColumns = solver_->getNumCols();
     15395  int nTree = CoinMax(10000,2*numberRows+numberColumns);
     15396  int nRoot = CoinMax(40000,8*numberRows+4*numberColumns);
     15397  for (int i = 0;i<numberHeuristics_;i++) {
     15398    CbcHeuristicDive * heuristic = dynamic_cast<CbcHeuristicDive *> (heuristic_[i]);
     15399    if (heuristic) {
     15400      heuristic->setMaxSimplexIterations(nTree);
     15401      heuristic->setMaxSimplexIterationsAtRoot(nRoot);
     15402    }
     15403  }
     15404}
  • trunk/Cbc/src/CbcModel.hpp

    r1087 r1088  
    14901490      9 bit (512) - Try reduced model after 100 nodes
    14911491      10 bit (1024) - Switch on some heuristics even if seems unlikely
     1492      11 bit (2048) - Mark as in small branch and bound
    14921493  */
    14931494  /// Set special options
     
    17381739  */
    17391740  void doHeuristicsAtRoot(int deleteHeuristicsAfterwards=0);
     1741  /// Adjust heuristics based on model
     1742  void adjustHeuristics();
    17401743  /// Get the hotstart solution
    17411744  inline const double * hotstartSolution() const
  • trunk/Cbc/src/CbcNode.cpp

    r1087 r1088  
    10751075    }
    10761076#endif
    1077     assert (lastws->fullBasis());
    10781077
    10791078/*
  • trunk/Cbc/src/CbcSolver.cpp

    r1087 r1088  
    489489  parameters_[whichParam(PREPROCESS,numberParameters_,parameters_)].setCurrentOption("sos");
    490490  parameters_[whichParam(MIPOPTIONS,numberParameters_,parameters_)].setIntValue(128|64|1);
    491   parameters_[whichParam(MIPOPTIONS,numberParameters_,parameters_)].setIntValue(1);
     491  parameters_[whichParam(MIPOPTIONS,numberParameters_,parameters_)].setIntValue(1025);
    492492  parameters_[whichParam(CUTPASSINTREE,numberParameters_,parameters_)].setIntValue(1);
    493493  parameters_[whichParam(MOREMIPOPTIONS,numberParameters_,parameters_)].setIntValue(-1);
     
    31923192  parameters[whichParam(PREPROCESS,numberParameters,parameters)].setCurrentOption("sos");
    31933193  parameters[whichParam(MIPOPTIONS,numberParameters,parameters)].setIntValue(128|64|1);
    3194   parameters[whichParam(MIPOPTIONS,numberParameters,parameters)].setIntValue(1);
     3194  parameters[whichParam(MIPOPTIONS,numberParameters,parameters)].setIntValue(1025);
    31953195  parameters[whichParam(CUTPASSINTREE,numberParameters,parameters)].setIntValue(1);
    31963196  parameters[whichParam(MOREMIPOPTIONS,numberParameters,parameters)].setIntValue(-1);
     
    36633663  // Statistics
    36643664  double statistics_seconds=0.0, statistics_obj=0.0;
     3665  double statistics_sys_seconds=0.0, statistics_elapsed_seconds=0.0;
     3666  CoinWallclockTime();
    36653667  double statistics_continuous=0.0, statistics_tighter=0.0;
    36663668  double statistics_cut_time=0.0;
     
    57525754                    <<CoinMessageEol;
    57535755                }
    5754                 if (false) {
     5756                if (model_.getMaximumNodes()==-987654321) {
    57555757                  // See if No objective!
    57565758                  int numberColumns = clpSolver->getNumCols();
     
    57645766                  }
    57655767                  if (!nObj) {
    5766                     printf("No objective!!\n");
     5768                    printf("************No objective!!\n");
    57675769                    model_.setMaximumSolutions(1);
    57685770                    // Column copy
     
    57745776                    for (int i=0;i<numberColumns;i++) {
    57755777                      double value = (CoinDrand48()+0.5)*10000;
     5778                      value = 10;
    57765779                      value *= columnLength[i];
    57775780                      int iValue = ((int) value)/10;
     
    65076510              OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (babModel_->solver());
    65086511              // go faster stripes
    6509               if (osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
     6512              if ((osiclp->getNumRows()<300&&osiclp->getNumCols()<500)) {
    65106513                osiclp->setupForRepeatedUse(2,parameters_[slog].intValue());
    65116514                if (bothFlags>=1) {
     
    65386541              // Used to be automatically set
    65396542              int mipOptions = parameters_[whichParam(MIPOPTIONS,numberParameters_,parameters_)].intValue()%10000;
    6540               if (mipOptions!=(1)) {
     6543              if (mipOptions!=(1025)) {
    65416544                sprintf(generalPrint,"mip options %d",mipOptions);
    65426545                generalMessageHandler->message(CLP_GENERAL,generalMessages)
     
    76017604                if (denseCode>0)
    76027605                  lpSolver->factorization()->setGoDenseThreshold(denseCode);
    7603                 if (smallCode>0)
     7606                if (smallCode>0&&smallCode>denseCode)
    76047607                  lpSolver->factorization()->setGoSmallThreshold(smallCode);
    76057608                //if (denseCode>=lpSolver->numberRows()) {
     
    80218024                int iStat2 = babModel_->secondaryStatus();
    80228025                statistics_seconds=time2-time1;
     8026                statistics_sys_seconds=CoinSysTime();
     8027                statistics_elapsed_seconds=CoinWallclockTime();
    80238028                statistics_obj=babModel_->getObjValue();
    80248029                statistics_continuous=babModel_->getContinuousObjective();
     
    95189523                // first header if needed
    95199524                if (state!=2) {
    9520                   fprintf(fp,"Name,result,time,objective,continuous,tightened,cut_time,nodes,iterations,rows,columns,processed_rows,processed_columns");
     9525                  fprintf(fp,"Name,result,time,sys,elapsed,objective,continuous,tightened,cut_time,nodes,iterations,rows,columns,processed_rows,processed_columns");
    95219526                  for (int i=0;i<statistics_number_generators;i++)
    95229527                    fprintf(fp,",%s",statistics_name_generators[i]);
     
    95309535                    slash=buffer+i+1;
    95319536                }
    9532                 fprintf(fp,"%s,%s,%.2f,%.16g,%g,%g,%.2f,%d,%d,%d,%d,%d,%d",
    9533                         slash,statistics_result.c_str(),statistics_seconds,statistics_obj,
     9537                fprintf(fp,"%s,%s,%.2f,%.2f,%.2f,%.16g,%g,%g,%.2f,%d,%d,%d,%d,%d,%d",
     9538                        slash,statistics_result.c_str(),statistics_seconds,
     9539                        statistics_sys_seconds,statistics_elapsed_seconds,
     9540                        statistics_obj,
    95349541                        statistics_continuous,statistics_tighter,statistics_cut_time,statistics_nodes,
    95359542                        statistics_iterations,statistics_nrows,statistics_ncols,
Note: See TracChangeset for help on using the changeset viewer.