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

dynamic branching stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.