Changeset 147


Ignore:
Timestamp:
Jun 8, 2005 12:13:14 PM (15 years ago)
Author:
forrest
Message:

dynamic branching stuff

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcBranchDynamic.cpp

    r137 r147  
    273273  else
    274274    preferredWay=-1;
     275  // weight at 1.0 is max min
    275276#define WEIGHT_AFTER 0.8
     277#define WEIGHT_BEFORE 0.3
    276278  if (fabs(value-nearest)<=integerTolerance) {
    277279    return 0.0;
     
    281283    double minValue = CoinMin(downCost,upCost);
    282284    double maxValue = CoinMax(downCost,upCost);
    283     if (stateOfSearch==0) {
     285    if (stateOfSearch<=1||model_->currentNode()->depth()<=10) {
    284286      // no solution
    285       returnValue = 0.5*minValue + 0.5*maxValue;
     287      returnValue = WEIGHT_BEFORE*minValue + (1.0-WEIGHT_BEFORE)*maxValue;
    286288    } else {
    287289      // some solution
     
    681683  int betterWay=0;
    682684  double value=0.0;
    683   if (!stateOfSearch) {
     685  if (stateOfSearch<=1||thisOne->model()->currentNode()->depth()<=10) {
     686#if 0
    684687    if (!bestObject_) {
    685688      bestNumberUp_=INT_MAX;
     
    723726      value = CoinMin(numInfUp,numInfDown);
    724727    }
     728#else
     729    if (!bestObject_) {
     730      bestCriterion_=-1.0;
     731    }
     732    // got a solution
     733    double minValue = CoinMin(changeDown,changeUp);
     734    double maxValue = CoinMax(changeDown,changeUp);
     735    value = WEIGHT_BEFORE*minValue + (1.0-WEIGHT_BEFORE)*maxValue;
     736    if (value>bestCriterion_+1.0e-8) {
     737      if (changeUp<=changeDown) {
     738        betterWay=1;
     739      } else {
     740        betterWay=-1;
     741      }
     742    }
     743#endif
    725744  } else {
    726745    if (!bestObject_) {
  • trunk/CbcModel.cpp

    r146 r147  
    31833183        // update size of problem
    31843184        numberRowsAtContinuous_ = solver_->getNumRows() ;
    3185 #if 0
     3185#ifdef COIN_USE_CLP
    31863186        OsiClpSolverInterface * clpSolver
    31873187          = dynamic_cast<OsiClpSolverInterface *> (solver_);
  • trunk/Samples/sample2.cpp

    r117 r147  
    1717#include "CbcCutGenerator.hpp"
    1818#include "CbcHeuristicUser.hpp"
    19 #ifdef COIN_USE_CLP
    2019#include "OsiClpSolverInterface.hpp"
    21 #endif
    22 #ifdef COIN_USE_OSL
    23 #include "OsiOslSolverInterface.hpp"
    24 #endif
    2520
    2621// Cuts
     
    3227#include "CglClique.hpp"
    3328#include "CglFlowCover.hpp"
    34 #include "CglMixedIntegerRounding.hpp"
     29#include "CglMixedIntegerRounding2.hpp"
    3530// Preprocessing
    3631#include "CglPreProcess.hpp"
     
    7368  // Define your favorite OsiSolver
    7469 
    75 #ifdef COIN_USE_CLP
    7670  OsiClpSolverInterface solver1;
    77 #elif COIN_USE_OSL
    78   OsiOslSolverInterface solver1;
    79 #endif
    8071
    8172  // Read in model using argv[1]
     
    142133  CglProbing generator1;
    143134  generator1.setUsingObjective(true);
    144   generator1.setMaxPass(3);
     135  generator1.setMaxPass(1);
     136  generator1.setMaxPassRoot(5);
    145137  // Number of unsatisfied variables to look at
    146138  generator1.setMaxProbe(10);
     139  generator1.setMaxProbeRoot(1000);
    147140  // How far to follow the consequences
    148141  generator1.setMaxLook(50);
     142  generator1.setMaxLookRoot(500);
    149143  // Only look at rows with fewer than this number of elements
    150144  generator1.setMaxElements(200);
     
    168162  generator5.setRowCliqueReport(false);
    169163
    170   CglMixedIntegerRounding mixedGen;
     164  CglMixedIntegerRounding2 mixedGen;
    171165  CglFlowCover flowGen;
    172166 
     
    187181    generator->setTiming(true);
    188182  }
    189 #ifdef COIN_USE_CLP
    190183  OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver());
    191184  // go faster stripes
    192185  if (osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
    193186    osiclp->setupForRepeatedUse(2,0);
    194     printf("trying slightly less reliable but faster version (? Gomory cuts okay?)\n");
    195     printf("may not be safe if doing cuts in tree which need accuracy (level 2 anyway)\n");
    196   }
    197 #endif
    198 
     187  }
     188  model.messagesPointer()->setDetailMessage(0,61);
    199189  // Allow rounding heuristic
    200190
     
    219209
    220210  // Could tune more
    221   model.setMinimumDrop(min(1.0,
    222                              fabs(model.getMinimizationObjValue())*1.0e-3+1.0e-4));
     211  double objValue = model.solver()->getObjSense()*model.solver()->getObjValue();
     212  double minimumDropA=CoinMin(1.0,fabs(objValue)*1.0e-3+1.0e-4);
     213  double minimumDrop= fabs(objValue)*1.0e-4+1.0e-4;
     214  printf("min drop %g (A %g)\n",minimumDrop,minimumDropA);
     215  model.setMinimumDrop(minimumDrop);
    223216
    224217  if (model.getNumCols()<500)
     
    228221  else
    229222    model.setMaximumCutPassesAtRoot(20);
    230   //model.setMaximumCutPasses(5);
     223  model.setMaximumCutPasses(10);
     224  //model.setMaximumCutPasses(2);
    231225
    232226  // Switch off strong branching if wanted
     
    235229  if (model.getNumCols()<5000)
    236230    model.setNumberStrong(10);
     231  model.setNumberStrong(20);
    237232
    238233  model.solver()->setIntParam(OsiMaxNumIterationHotStart,100);
     
    254249  //model.solver()->messageHandler()->setLogLevel(2);
    255250  //model.setPrintFrequency(50);
     251  //#define DEBUG_CUTS
    256252#ifdef DEBUG_CUTS
    257253  // Set up debugger by name (only if no preprocesing)
     
    288284      std::cout<<std::endl;
    289285  }
    290   // Print solution if finished - we can't get names from Osi!
     286  // Print solution if finished - we can't get names from Osi! - so get from OsiClp
    291287
    292288  if (model.getMinimizationObjValue()<1.0e50) {
     
    303299   
    304300    const double * solution = solver->getColSolution();
     301
     302    // Get names from solver1 (as OsiSolverInterface may lose)
     303    std::vector<std::string> columnNames = *solver1.getModelPtr()->columnNames();
    305304   
    306305    int iColumn;
     
    311310      double value=solution[iColumn];
    312311      if (fabs(value)>1.0e-7&&solver->isInteger(iColumn))
    313         std::cout<<std::setw(6)<<iColumn<<" "<<value<<std::endl;
     312        std::cout<<std::setw(6)<<iColumn<<" "
     313                 <<columnNames[iColumn]<<" "
     314                 <<value<<std::endl;
    314315    }
    315316    std::cout<<"--------------------------------------"<<std::endl;
  • trunk/Test/CbcMain.cpp

    r122 r147  
    1414#include <iostream>
    1515
    16 #define CBCVERSION "0.93"
     16#define CBCVERSION "0.95"
    1717
    1818#include "CoinMpsIO.hpp"
Note: See TracChangeset for help on using the changeset viewer.