Changeset 2101
 Timestamp:
 Dec 3, 2014 12:43:20 PM (4 years ago)
 Location:
 trunk/Cbc
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/examples/driver4.cpp
r1898 r2101 12 12 #include "OsiClpSolverInterface.hpp" 13 13 #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" 14 20 15 21 #include "CoinTime.hpp" … … 70 76 case 3: 71 77 { 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) ; 72 152 //CbcCompareUser compare; 73 153 //model>setNodeComparison(compare); … … 76 156 case 4: 77 157 // If not good enough could skip postprocessing 78 break; 158 break; 79 159 case 5: 80 160 break; … … 229 309 */ 230 310 // Messy code below copied from CbcSolver.cpp 231 #ifdef CLP_FAST_CODE232 // force new style solver233 #ifndef NEW_STYLE_SOLVER234 #define NEW_STYLE_SOLVER 1235 #endif236 #else237 // Not new style solver238 #ifndef NEW_STYLE_SOLVER239 #define NEW_STYLE_SOLVER 0240 #endif241 #endif242 #if NEW_STYLE_SOLVER==0243 311 // Pass to Cbc initialize defaults 244 312 CbcModel modelA(solver1); … … 258 326 CbcMain1(3,argv2,modelA,callBack); 259 327 } 260 #else261 CbcSolver control(solver1);262 // initialize263 control.fillValuesInSolver();264 // Event handler265 MyEventHandler3 eventHandler;266 CbcModel * model = control.model();267 model>passInEventHandler(&eventHandler);268 control.solve (argc1, argv+1, 1);269 #endif270 328 // Solver was cloned so get current copy 271 329 OsiSolverInterface * solver = model>solver(); 
trunk/Cbc/src/CbcHeuristicDive.cpp
r2094 r2101 252 252 bool CbcHeuristicDive::canHeuristicRun() 253 253 { 254 if (model_>bestSolution() ) {254 if (model_>bestSolution()model_>getNodeCount()) { 255 255 if (when_==3  (when_==4 && numberSolutionsFound_) ) 256 256 return false; … … 275 275 int nRoundInfeasible = 0; 276 276 int nRoundFeasible = 0; 277 printf("Entering %s  fix %.1f%% maxTime %.2f maxPasses %d  max iterations %d (at root %d)  when to do %d\n", 278 heuristicName_.c_str(),percentageToFix_*100.0,maxTime_,maxIterations_, 279 maxSimplexIterations_,maxSimplexIterationsAtRoot_,when()); 277 280 #endif 278 281 int reasonToStop = 0;
Note: See TracChangeset
for help on using the changeset viewer.