Changeset 2101 for trunk/Cbc/examples


Ignore:
Timestamp:
Dec 3, 2014 12:43:20 PM (4 years ago)
Author:
forrest
Message:

minor print change to diving

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/examples/driver4.cpp

    r1898 r2101  
    1212#include "OsiClpSolverInterface.hpp"
    1313#include "CbcSolver.hpp"
     14#include "CbcHeuristicDiveCoefficient.hpp"
     15#include "CbcHeuristicDiveFractional.hpp"
     16#include "CbcHeuristicDiveGuided.hpp"
     17#include "CbcHeuristicDiveVectorLength.hpp"
     18#include "CbcHeuristicDivePseudoCost.hpp"
     19#include "CbcHeuristicDiveLineSearch.hpp"
    1420
    1521#include "CoinTime.hpp"
     
    7076  case 3:
    7177    {
     78      // Add in some diving heuristics with different options
     79      CbcHeuristicDiveCoefficient heuristicDC(*model);
     80      heuristicDC.setHeuristicName("DiveCoefficient");
     81      // do if no solution
     82      heuristicDC.setWhen(3);
     83      // 150 passes and fix general integers
     84      heuristicDC.setMaxIterations(151);
     85      // make sure can do as many simplex iterations as wanted
     86      heuristicDC.setMaxSimplexIterations(COIN_INT_MAX);
     87      heuristicDC.setMaxSimplexIterationsAtRoot(COIN_INT_MAX);
     88      model->addHeuristic(&heuristicDC) ;
     89      CbcHeuristicDiveFractional heuristicDF(*model);
     90      heuristicDF.setHeuristicName("DiveFractional");
     91      // do if no solution
     92      heuristicDF.setWhen(3);
     93      // 150 passes and don't fix general integers
     94      heuristicDF.setMaxIterations(150);
     95      // make sure can do as many simplex iterations as wanted
     96      heuristicDF.setMaxSimplexIterations(COIN_INT_MAX);
     97      heuristicDF.setMaxSimplexIterationsAtRoot(COIN_INT_MAX);
     98      model->addHeuristic(&heuristicDF) ;
     99      CbcHeuristicDiveGuided heuristicDG(*model);
     100      heuristicDG.setHeuristicName("DiveGuided");
     101      // do if no solution
     102      heuristicDG.setWhen(3);
     103      // 200 passes and fix general integers
     104      heuristicDG.setMaxIterations(201);
     105      // make sure can do as many simplex iterations as wanted
     106      heuristicDG.setMaxSimplexIterations(COIN_INT_MAX);
     107      heuristicDG.setMaxSimplexIterationsAtRoot(COIN_INT_MAX);
     108      model->addHeuristic(&heuristicDG) ;
     109      CbcHeuristicDiveVectorLength heuristicDV(*model);
     110      heuristicDV.setHeuristicName("DiveVectorLength");
     111      // do if no solution
     112      heuristicDV.setWhen(3);
     113      // 150 passes and fix general integers
     114      heuristicDV.setMaxIterations(151);
     115      // make sure can do as many simplex iterations as wanted
     116      heuristicDV.setMaxSimplexIterations(COIN_INT_MAX);
     117      heuristicDV.setMaxSimplexIterationsAtRoot(COIN_INT_MAX);
     118      model->addHeuristic(&heuristicDV) ;
     119      // Second version!
     120      CbcHeuristicDiveVectorLength heuristicDV2(*model);
     121      heuristicDV2.setHeuristicName("DiveVectorLength");
     122      // do if no solution
     123      heuristicDV2.setWhen(3);
     124      // 300 passes and don't fix general integers
     125      heuristicDV2.setMaxIterations(300);
     126      // fix fewer
     127      heuristicDV2.setPercentageToFix(0.05);
     128      // make sure can do as many simplex iterations as wanted
     129      heuristicDV2.setMaxSimplexIterations(COIN_INT_MAX);
     130      heuristicDV2.setMaxSimplexIterationsAtRoot(COIN_INT_MAX);
     131      model->addHeuristic(&heuristicDV2) ;
     132      CbcHeuristicDivePseudoCost heuristicDP(*model);
     133      heuristicDP.setHeuristicName("DivePseudoCost");
     134      // do if no solution
     135      heuristicDP.setWhen(3);
     136      // 100 passes and don't fix general integers
     137      heuristicDP.setMaxIterations(100);
     138      // make sure can do as many simplex iterations as wanted
     139      heuristicDP.setMaxSimplexIterations(COIN_INT_MAX);
     140      heuristicDP.setMaxSimplexIterationsAtRoot(COIN_INT_MAX);
     141      model->addHeuristic(&heuristicDP) ;
     142      CbcHeuristicDiveLineSearch heuristicDL(*model);
     143      heuristicDL.setHeuristicName("DiveLineSearch");
     144      // do if no solution
     145      heuristicDL.setWhen(3);
     146      // 150 passes and fix general integers
     147      heuristicDL.setMaxIterations(151);
     148      // make sure can do as many simplex iterations as wanted
     149      heuristicDL.setMaxSimplexIterations(COIN_INT_MAX);
     150      heuristicDL.setMaxSimplexIterationsAtRoot(COIN_INT_MAX);
     151      model->addHeuristic(&heuristicDL) ;
    72152      //CbcCompareUser compare;
    73153      //model->setNodeComparison(compare);
     
    76156  case 4:
    77157    // If not good enough could skip postprocessing
    78     break;
     158    break; 
    79159  case 5:
    80160    break;
     
    229309   */
    230310  // Messy code below copied from CbcSolver.cpp
    231 #ifdef CLP_FAST_CODE
    232 // force new style solver
    233 #ifndef NEW_STYLE_SOLVER
    234 #define NEW_STYLE_SOLVER 1
    235 #endif
    236 #else
    237 // Not new style solver
    238 #ifndef NEW_STYLE_SOLVER
    239 #define NEW_STYLE_SOLVER 0
    240 #endif
    241 #endif
    242 #if NEW_STYLE_SOLVER==0
    243311  // Pass to Cbc initialize defaults
    244312  CbcModel modelA(solver1);
     
    258326    CbcMain1(3,argv2,modelA,callBack);
    259327  }
    260 #else
    261   CbcSolver control(solver1);
    262   // initialize
    263   control.fillValuesInSolver();
    264   // Event handler
    265   MyEventHandler3 eventHandler;
    266   CbcModel * model = control.model();
    267   model->passInEventHandler(&eventHandler);
    268   control.solve (argc-1, argv+1, 1);
    269 #endif
    270328  // Solver was cloned so get current copy
    271329  OsiSolverInterface * solver = model->solver();
Note: See TracChangeset for help on using the changeset viewer.