Changeset 171 for trunk


Ignore:
Timestamp:
Oct 4, 2005 11:38:55 AM (16 years ago)
Author:
forrest
Message:

redow maxWhich

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcModel.cpp

    r165 r171  
    26812681  return ; }
    26822682
    2683 
    2684 
     2683// Collect coding to replace whichGenerator
     2684static int * newWhichGenerator(int numberNow, int numberAfter,
     2685                               int & maximumWhich, int * whichGenerator)
     2686{
     2687  if (numberAfter > maximumWhich) {
     2688    maximumWhich = CoinMax(maximumWhich*2+100,numberAfter) ;
     2689    int * temp = new int[2*maximumWhich] ;
     2690    memcpy(temp,whichGenerator,numberNow*sizeof(int)) ;
     2691    delete [] whichGenerator ;
     2692    whichGenerator = temp ;
     2693  }
     2694  return whichGenerator;
     2695}
    26852696
    26862697/** Solve the model using cuts
     
    28702881    { int numberCuts = globalCuts_.sizeColCuts() ;
    28712882      int i;
     2883      // possibly extend whichGenerator
     2884      whichGenerator = newWhichGenerator(numberViolated, numberViolated+numberCuts,
     2885                                         maximumWhich,  whichGenerator);
    28722886      for ( i = 0 ; i < numberCuts ; i++)
    28732887      { const OsiColCut *thisCut = globalCuts_.colCutPtr(i) ;
     
    28802894      }
    28812895      numberCuts = globalCuts_.sizeRowCuts() ;
     2896      // possibly extend whichGenerator
     2897      whichGenerator = newWhichGenerator(numberViolated, numberViolated+numberCuts,
     2898                                         maximumWhich,  whichGenerator);
    28822899      for ( i = 0;i<numberCuts;i++) {
    28832900        const OsiRowCut * thisCut = globalCuts_.rowCutPtr(i) ;
     
    29242941      if (handler_->logLevel()>1)
    29252942        printf("applying branch cut, sum is %g, bounds %g %g\n",sum,lb,ub);
     2943      // possibly extend whichGenerator
     2944      whichGenerator = newWhichGenerator(numberViolated, numberViolated+1,
     2945                                         maximumWhich,  whichGenerator);
    29262946      // set whichgenerator (also serves as marker to say don't delete0
    29272947      whichGenerator[numberViolated++]=-2;
     
    30133033  lastNumberCuts is the sum of cuts added in previous iterations; it's the
    30143034  offset to the proper starting position in whichGenerator.
    3015 
    3016   TODO: Why is whichGenerator increased to 2*maximumWhich when it grows?
    30173035*/
    30183036      int numberBefore =
     
    30203038      int numberAfter =
    30213039            numberRowCutsAfter+numberColumnCutsAfter+lastNumberCuts ;
    3022       if (numberAfter > maximumWhich) {
    3023         maximumWhich = CoinMax(maximumWhich*2+100,numberAfter) ;
    3024         int * temp = new int[2*maximumWhich] ;
    3025         memcpy(temp,whichGenerator,numberBefore*sizeof(int)) ;
    3026         delete [] whichGenerator ;
    3027         whichGenerator = temp ;
    3028       }
     3040      // possibly extend whichGenerator
     3041      whichGenerator = newWhichGenerator(numberBefore, numberAfter,
     3042                                         maximumWhich,  whichGenerator);
    30293043      int j ;
    30303044      if (fullScan) {
Note: See TracChangeset for help on using the changeset viewer.