Changeset 135 for trunk/CbcStrategy.cpp


Ignore:
Timestamp:
May 19, 2005 11:24:16 AM (15 years ago)
Author:
forrest
Message:

starting dynamic pseudo costs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcStrategy.cpp

    r116 r135  
    4242CbcStrategyDefault::CbcStrategyDefault(bool cutsOnlyAtRoot,
    4343                                       int numberStrong,
     44                                       int numberBeforeTrust,
    4445                                       int printLevel)
    4546  :CbcStrategy(),
    4647   cutsOnlyAtRoot_(cutsOnlyAtRoot),
    4748   numberStrong_(numberStrong),
     49   numberBeforeTrust_(numberBeforeTrust),
    4850   printLevel_(printLevel)
    4951{
     
    6971  cutsOnlyAtRoot_(rhs.cutsOnlyAtRoot_),
    7072  numberStrong_(rhs.numberStrong_),
     73  numberBeforeTrust_(rhs.numberBeforeTrust_),
    7174  printLevel_(rhs.printLevel_)
    7275{
     
    8386  CglProbing generator1;
    8487  generator1.setUsingObjective(true);
    85   generator1.setMaxPass(3);
     88  generator1.setMaxPass(1);
    8689  // Number of unsatisfied variables to look at
    8790  generator1.setMaxProbe(10);
    8891  // How far to follow the consequences
    89   generator1.setMaxLook(50);
     92  generator1.setMaxLook(10);
    9093  // Only look at rows with fewer than this number of elements
    9194  generator1.setMaxElements(200);
    92   generator1.setRowCuts(3);
     95  //generator1.setRowCuts(3);
    9396
    9497  CglGomory generator2;
     
    113116  // Add in generators
    114117  int setting = cutsOnlyAtRoot_ ? -99 : -1;
    115 
    116   model.addCutGenerator(&generator1,setting,"Probing");
    117   model.addCutGenerator(&generator2,setting,"Gomory");
    118   model.addCutGenerator(&generator3,setting,"Knapsack");
    119   //model.addCutGenerator(&generator4,setting,"OddHole");
    120   model.addCutGenerator(&generator5,setting,"Clique");
    121   model.addCutGenerator(&flowGen,setting,"FlowCover");
    122   model.addCutGenerator(&mixedGen,setting,"MixedIntegerRounding");
    123   // Say we want timings
    124118  int numberGenerators = model.numberCutGenerators();
    125119  int iGenerator;
    126   for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     120  bool found;
     121  found=false;
     122  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     123    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
     124    CglProbing * cgl = dynamic_cast<CglProbing *>(generator);
     125    if (cgl) {
     126      found=true;
     127      break;
     128    }
     129  }
     130  if (!found)
     131    model.addCutGenerator(&generator1,setting,"Probing");
     132  found=false;
     133  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     134    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
     135    CglGomory * cgl = dynamic_cast<CglGomory *>(generator);
     136    if (cgl) {
     137      found=true;
     138      break;
     139    }
     140  }
     141  if (!found)
     142  model.addCutGenerator(&generator2,setting,"Gomory");
     143  found=false;
     144  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     145    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
     146    CglKnapsackCover * cgl = dynamic_cast<CglKnapsackCover *>(generator);
     147    if (cgl) {
     148      found=true;
     149      break;
     150    }
     151  }
     152  if (!found)
     153    model.addCutGenerator(&generator3,setting,"Knapsack");
     154  //model.addCutGenerator(&generator4,setting,"OddHole");
     155  found=false;
     156  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     157    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
     158    CglClique * cgl = dynamic_cast<CglClique *>(generator);
     159    if (cgl) {
     160      found=true;
     161      break;
     162    }
     163  }
     164  if (!found)
     165    model.addCutGenerator(&generator5,setting,"Clique");
     166  found=false;
     167  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     168    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
     169    CglFlowCover * cgl = dynamic_cast<CglFlowCover *>(generator);
     170    if (cgl) {
     171      found=true;
     172      break;
     173    }
     174  }
     175  if (!found)
     176    model.addCutGenerator(&flowGen,setting,"FlowCover");
     177  found=false;
     178  for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
     179    CglCutGenerator * generator = model.cutGenerator(iGenerator)->generator();
     180    CglMixedIntegerRounding * cgl = dynamic_cast<CglMixedIntegerRounding *>(generator);
     181    if (cgl) {
     182      found=true;
     183      break;
     184    }
     185  }
     186  if (!found)
     187    model.addCutGenerator(&mixedGen,setting,"MixedIntegerRounding");
     188  // Say we want timings
     189  int newNumberGenerators = model.numberCutGenerators();
     190  for (iGenerator=numberGenerators;iGenerator<newNumberGenerators;iGenerator++) {
    127191    CbcCutGenerator * generator = model.cutGenerator(iGenerator);
    128192    generator->setTiming(true);
     
    142206
    143207  CbcRounding heuristic1(model);
    144   model.addHeuristic(&heuristic1);
     208  int numberHeuristics = model.numberHeuristics();
     209  int iHeuristic;
     210  bool found;
     211  found=false;
     212  for (iHeuristic=0;iHeuristic<numberHeuristics;iHeuristic++) {
     213    CbcHeuristic * heuristic = model.heuristic(iHeuristic);
     214    CbcRounding * cgl = dynamic_cast<CbcRounding *>(heuristic);
     215    if (cgl) {
     216      found=true;
     217      break;
     218    }
     219  }
     220  if (!found)
     221    model.addHeuristic(&heuristic1);
    145222}
    146223// Do printing stuff
     
    163240{
    164241  model.setNumberStrong(numberStrong_);
     242  model.setNumberBeforeTrust(numberBeforeTrust_);
    165243}
    166244
Note: See TracChangeset for help on using the changeset viewer.