Changeset 1219


Ignore:
Timestamp:
Aug 29, 2009 11:43:24 AM (10 years ago)
Author:
forrest
Message:

changes to think about heuristic changes

Location:
trunk/Cbc/src
Files:
10 edited

Legend:

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

    r1173 r1219  
    293293#define TRY_THIS 0
    294294#if TRY_THIS==0
    295     double weight = CoinMax(weight_,0.0);
     295    double weight = CoinMax(weight_,1.0e-9);
    296296    double testX =  x->objectiveValue()+ weight*x->numberUnsatisfied();
    297297    double testY = y->objectiveValue() + weight*y->numberUnsatisfied();
  • trunk/Cbc/src/CbcHeuristic.cpp

    r1212 r1219  
    104104  decayFactor_(0.0),
    105105  switches_(0),
    106   whereFrom_(255),
     106  whereFrom_((255-2-16)*(1+256)),
    107107  shallowDepth_(1),
    108108  howOftenShallow_(1),
     
    131131  decayFactor_(0.0),
    132132  switches_(0),
    133   whereFrom_(255),
     133  whereFrom_((255-2-16)*(1+256)),
    134134  shallowDepth_(1),
    135135  howOftenShallow_(1),
     
    264264CbcHeuristic::shouldHeurRun(int whereFrom)
    265265{
    266   assert (whereFrom>=0&&whereFrom<8);
     266  assert (whereFrom>=0&&whereFrom<16);
     267  // take off 8 (code - likes new solution)
     268  whereFrom &= 7;
    267269  if ((whereFrom_&(1<<whereFrom))==0)
    268270    return false;
  • trunk/Cbc/src/CbcHeuristic.hpp

    r1211 r1219  
    216216  /** Check whether the heuristic should run at all
    217217      0 - before cuts at root node (or from doHeuristics)
    218       1 - before cuts at other nodes
     218      1 - during cuts at root
    219219      2 - after root node cuts
    220220      3 - after cuts at other nodes
    221           4 added if previous heuristic in loop found solution
     221      4 - during cuts at other nodes
     222          8 added if previous heuristic in loop found solution
    222223  */
    223224  virtual bool shouldHeurRun(int whereFrom);
     
    272273  /* Runs if bit set
    273274      0 - before cuts at root node (or from doHeuristics)
    274       1 - before cuts at other nodes
     275      1 - during cuts at root
    275276      2 - after root node cuts
    276277      3 - after cuts at other nodes
    277           4 added if previous heuristic in loop found solution
     278      4 - during cuts at other nodes
     279          8 added if previous heuristic in loop found solution
    278280   */
    279281  int whereFrom_;
  • trunk/Cbc/src/CbcHeuristicDive.cpp

    r1211 r1219  
    3030  maxSimplexIterationsAtRoot_ = 1000000;
    3131  maxTime_ = 600;
    32   whereFrom_=16+15;
     32  whereFrom_=255-2-16+256;
    3333}
    3434
     
    5353  maxSimplexIterationsAtRoot_ = 1000000;
    5454  maxTime_ = 600;
    55   whereFrom_=16+15;
     55  whereFrom_=255-2-16+256;
    5656}
    5757
  • trunk/Cbc/src/CbcHeuristicFPump.cpp

    r1212 r1219  
    214214  int passNumber = model_->getCurrentPassNumber();
    215215  // just do once
    216   if (!atRoot||passNumber!=1)
     216  if (!atRoot)
    217217    return 0;
    218   // probably a good idea
    219   //if (model_->getSolutionCount()) return 0;
     218  int options = feasibilityPumpOptions_;
     219  if ((options%1000000)>0) {
     220    int kOption = options/1000000;
     221    options = options%1000000;
     222    /*
     223      Add 10 to do even if solution
     224      1 - do after cuts
     225      2 - do after cuts (not before)
     226      3 - not used do after every cut round (and after cuts)
     227      k not used do after every (k-2)th round
     228    */
     229    if (kOption<10&&model_->getSolutionCount())
     230      return 0;
     231    if (model_->getSolutionCount())
     232    kOption = kOption %10;
     233    bool good;
     234    if (kOption==1) {
     235      good = (passNumber==999999);
     236    } else if (kOption==2) {
     237      good = (passNumber==999999);
     238      passNumber=2; // so won't run before
     239      //} else if (kOption==3) {
     240      //good = true;
     241    } else {
     242      //good = (((passNumber-1)%(kOption-2))==0);
     243      good = false;
     244    }
     245    if (passNumber!=1&&!good)
     246      return 0;
     247  } else {
     248    if (passNumber!=1)
     249      return 0;
     250  }
    220251  // loop round doing repeated pumps
    221252  double cutoff;
     
    366397  int maximumAllowed=-1;
    367398  bool moreIterations=false;
    368   if (feasibilityPumpOptions_>0) {
    369     if (feasibilityPumpOptions_>=1000)
    370       maximumAllowed = feasibilityPumpOptions_/1000;
    371     int options2 = (feasibilityPumpOptions_%1000)/100;
     399  if (options>0) {
     400    if (options>=1000)
     401      maximumAllowed = options/1000;
     402    int options2 = (options%1000)/100;
    372403#ifdef RAND_RAND
    373404    offRandom=options2&1;
    374405#endif
    375406    moreIterations = (options2&2)!=0;
    376     secondPassOpt = (feasibilityPumpOptions_/10)%10;
     407    secondPassOpt = (options/10)%10;
    377408    /* 1 to 7 - re-use solution
    378409       8 use dual and current solution(ish)
  • trunk/Cbc/src/CbcHeuristicFPump.hpp

    r1200 r1219  
    129129       2 - reuse solves, do not accumulate integer solutions for local search
    130130       3 - reuse solves, accumulate integer solutions for local search
     131       If we add 4 then use second form of problem (with extra rows and variables for general integers)
     132       If we add 8 then can run after initial cuts (if no solution)
    131133  */
    132134  inline void setAccumulate(int value)
     
    199201       If we do not accumulate solutions then no mini branch and bounds will be done
    200202       reuse - refers to initial solve after adding in new "cut"
     203       If we add 8 then can run after initial cuts (if no solution)
    201204  */
    202205  int accumulate_;
  • trunk/Cbc/src/CbcHeuristicRINS.cpp

    r1211 r1219  
    3030  decayFactor_ = 0.5;
    3131  used_=NULL;
    32   whereFrom_=255-15+1+8;
     32  whereFrom_=1+8+255*256;
    3333}
    3434
     
    4848  used_ = new char[numberColumns];
    4949  memset(used_,0,numberColumns);
    50   whereFrom_=255-15+1+8;
     50  whereFrom_=1+8+255*256;
    5151}
    5252
     
    266266{
    267267  numberTries_=0;
    268   whereFrom_=16+1;
     268  whereFrom_=256+1;
    269269}
    270270
     
    275275{
    276276  numberTries_=0;
    277   whereFrom_=16+1;
     277  whereFrom_=256+1;
    278278}
    279279
  • trunk/Cbc/src/CbcModel.cpp

    r1216 r1219  
    554554        //const CoinBigIndex * columnStart = matrixByCol.getVectorStarts();
    555555        const int * columnLength = matrixByCol->getVectorLengths();
     556        const double * solution = clpSolver->getColSolution();
     557#if 0
     558        int nAtBound=0;
     559        for (int i=0;i<numberColumns;i++) {
     560          double lowerValue=lower[i];
     561          double upperValue=upper[i];
     562          if (clpSolver->isInteger(i)) {
     563            double lowerValue=lower[i];
     564            double upperValue=upper[i];
     565            double value=solution[i];
     566            if (value<lowerValue+1.0e-6||
     567                value>upperValue-1.0e-6)
     568              nAtBound++;
     569          }
     570        }
     571#endif
    556572        for (int i=0;i<numberColumns;i++) {
    557573          double lowerValue=lower[i];
     
    564580            if (fabs(lowerValue)>fabs(upperValue))
    565581              value = - value;
     582            if (clpSolver->isInteger(i)) {
     583              double solValue=solution[i];
     584              // Better to add in 0.5 or 1.0??
     585              if (solValue<lowerValue+1.0e-6)
     586                value = fabs(value)+0.5; //fabs(value*1.5);
     587              else if (solValue>upperValue-1.0e-6)
     588                value = -fabs(value)-0.5; //-fabs(value*1.5);
     589            }
    566590          } else {
    567591            value=0.0;
    568592          }
    569           if (clpSolver->isInteger(i))
    570             value *= 100;
    571593          fakeObj[i]=value;
    572594        }
     
    23712393       if (debugger) {
    23722394         printf("Contains optimal\n") ;
     2395         OsiSolverInterface * temp = saveSolver->clone();
     2396         const double * solution = debugger->optimalSolution();
     2397         const double *lower = temp->getColLower() ;
     2398         const double *upper = temp->getColUpper() ;
     2399         int n=temp->getNumCols();
     2400         for (int i=0;i<n;i++) {
     2401           if (temp->isInteger(i)) {
     2402             double value = floor(solution[i]+0.5);
     2403             assert (value>=lower[i]&&value<=upper[i]);
     2404             temp->setColLower(i,value);
     2405             temp->setColUpper(i,value);
     2406           }
     2407         }
     2408         temp->writeMps("reduced_fix");
     2409         delete temp;
    23732410         saveSolver->writeMps("reduced");
    23742411       } else {
     
    32083245            if (debugger) {
    32093246              printf("Contains optimal\n") ;
     3247              OsiSolverInterface * temp = saveSolver->clone();
     3248              const double * solution = debugger->optimalSolution();
     3249              const double *lower = temp->getColLower() ;
     3250              const double *upper = temp->getColUpper() ;
     3251              int n=temp->getNumCols();
     3252              for (int i=0;i<n;i++) {
     3253                if (temp->isInteger(i)) {
     3254                  double value = floor(solution[i]+0.5);
     3255                  assert (value>=lower[i]&&value<=upper[i]);
     3256                  temp->setColLower(i,value);
     3257                  temp->setColUpper(i,value);
     3258                }
     3259              }
     3260              temp->writeMps("reduced_fix");
     3261              delete temp;
    32103262              saveSolver->writeMps("reduced");
    32113263            } else {
     
    74457497  - unless at root node and first pass
    74467498*/
    7447     if ((numberNodes_||currentPassNumber_!=1)&&false) {
     7499    if ((numberNodes_||currentPassNumber_!=1)&&true) {
    74487500      double * newSolution = new double [numberColumns] ;
    74497501      double heuristicValue = getCutoff() ;
    74507502      int found = -1; // no solution found
    7451       int whereFrom = 3;
     7503      int whereFrom = numberNodes_ ? 4 : 1;
    74527504      for (i = 0;i<numberHeuristics_;i++) {
    74537505        // skip if can't run here
     
    74717523#endif
    74727524          setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
    7473           whereFrom |= 4; // say solution found
     7525          whereFrom |= 8; // say solution found
    74747526        } else if (ifSol<0) {
    74757527          heuristicValue = saveValue ;
     
    79337985#endif
    79347986          setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
    7935           whereFrom |= 4; // say solution found
     7987          whereFrom |= 8; // say solution found
    79367988        } else {
    79377989          heuristicValue = saveValue ;
     
    1232512377#endif
    1232612378            setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
    12327             whereFrom |= 4; // say solution found
     12379            whereFrom |= 8; // say solution found
    1232812380            if (heuristic_[i]->exitNow(bestObjective_))
    1232912381              break;
     
    1235812410      CbcHeuristicFPump * pump
    1235912411        = dynamic_cast<CbcHeuristicFPump *> (heuristic_[i]);
    12360       if (pump) {
     12412      if (pump&&pump->feasibilityPumpOptions()<1000000) {
    1236112413        delete pump;
    1236212414        numberHeuristics_ --;
     
    1345213504                setBestSolution(CBC_ROUNDING,heurValue,newSolution) ;
    1345313505                foundSolution=1;
    13454                 whereFrom |= 4; // say solution found
     13506                whereFrom |= 8; // say solution found
    1345513507              }
    1345613508            } else if (ifSol < 0)       { // just returning an estimate
     
    1492714979            found=iHeuristic;
    1492814980            incrementUsed(newSolution);
    14929             whereFrom |= 4; // say solution found
     14981            whereFrom |= 8; // say solution found
    1493014982          } else if (ifSol<0) {
    1493114983            heuristicValue = saveValue;
  • trunk/Cbc/src/CbcSolver.cpp

    r1217 r1219  
    33253325    int pumpTune2=parameters_[whichParam(FPUMPTUNE2,numberParameters_,parameters_)].intValue();
    33263326    if (pumpTune>0) {
    3327       bool printStuff = (pumpTune!=initialPumpTune||logLevel>1)
     3327      bool printStuff = (pumpTune!=initialPumpTune||logLevel>1||pumpTune2>0)
    33283328        &&!noPrinting_;
    33293329      if (printStuff) {
     
    33333333      }
    33343334      /*
    3335         >=10000000 for using obj
     3335        >=10000000 for using obj 
    33363336        >=1000000 use as accumulate switch
    33373337        >=1000 use index+1 as number of large loops
     
    33873387      int offRandomEtc=0;
    33883388      if (pumpTune2) {
     3389        if ((pumpTune2/1000)!=0) {
     3390          offRandomEtc = 1000000*(pumpTune2/1000);
     3391          if (printStuff) {
     3392            generalMessageHandler->message(CBC_GENERAL,generalMessages)
     3393              << "Feasibility pump may run twice"
     3394              <<CoinMessageEol;
     3395          }
     3396          pumpTune2 = pumpTune2%1000;
     3397        }
    33893398        if ((pumpTune2/100)!=0) {
    3390           offRandomEtc=100*(pumpTune2/100);
     3399          offRandomEtc+=100*(pumpTune2/100);
    33913400          if (printStuff) {
    33923401            generalMessageHandler->message(CBC_GENERAL,generalMessages)
     
    47324741                strongChanged=true;
    47334742              else if (parameters_[iParam].type()==FPUMPTUNE||
     4743                       parameters_[iParam].type()==FPUMPTUNE2||
    47344744                       parameters_[iParam].type()==FPUMPITS)
    47354745                pumpChanged=true;
  • trunk/Cbc/src/unitTestClp.cpp

    r1215 r1219  
    507507        model->solver()->activateRowCutDebugger(problemName.c_str()) ;
    508508      }
     509      if (model->getNumCols()==-1224&&model->getNumRows()<1380) {
     510        //PUSH_MPS("gesa2_o",1248,1224,25779856.372,25476489.678,1);
     511        // gesa2_o
     512        std::string problemName ;
     513        model->solver()->getStrParam(OsiProbName,problemName) ;
     514        model->solver()->activateRowCutDebugger(problemName.c_str()) ;
     515      }
    509516      if (model->getNumCols()==-1152&&model->getNumRows()==1368) {
    510517        //PUSH_MPS("gesa3",1368,1152,27991042.648,27833632.451,7);
Note: See TracChangeset for help on using the changeset viewer.