Changeset 1835 for stable/2.7/Cbc/src
 Timestamp:
 Dec 21, 2012 4:30:02 AM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

stable/2.7/Cbc/src/CbcHeuristic.cpp
r1731 r1835 118 118 numCouldRun_(0), 119 119 numberSolutionsFound_(0), 120 numberNodesDone_(0), 120 121 inputSolution_(NULL) 121 122 { … … 145 146 numCouldRun_(0), 146 147 numberSolutionsFound_(0), 148 numberNodesDone_(0), 147 149 inputSolution_(NULL) 148 150 {} … … 172 174 runNodes_ = rhs.runNodes_; 173 175 numberSolutionsFound_ = rhs.numberSolutionsFound_; 176 numberNodesDone_ = rhs.numberNodesDone_; 174 177 if (rhs.inputSolution_) { 175 178 int numberColumns = model_>getNumCols(); … … 453 456 CbcHeuristic::setSeed(int value) 454 457 { 458 if (value==0) { 459 double time = fabs(CoinGetTimeOfDay()); 460 while (time>=COIN_INT_MAX) 461 time *= 0.5; 462 value = static_cast<int>(time); 463 char printArray[100]; 464 sprintf(printArray, "using time of day seed was changed from %d to %d", 465 randomNumberGenerator_.getSeed(), value); 466 if (model_) 467 model_>messageHandler()>message(CBC_FPUMP1, model_>messages()) 468 << printArray 469 << CoinMessageEol; 470 } 455 471 randomNumberGenerator_.setSeed(value); 456 472 } … … 707 723 { 708 724 int saveLogLevel = solver>messageHandler()>logLevel(); 709 if (saveLogLevel == 1) 725 if (saveLogLevel == 1) 710 726 solver>messageHandler()>setLogLevel(0); 711 727 OsiPresolve * pinfo = new OsiPresolve(); … … 838 854 if (solver>isProvenOptimal()) { 839 855 CglPreProcess process; 856 OsiSolverInterface * solver2 = NULL; 840 857 if ((model_>moreSpecialOptions()&65536)!=0) 841 858 process.setOptions(2+4+8); // no cuts 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 /* Do not try and produce equality cliques and 860 do up to 2 passes (normally) 5 if restart */ 861 int numberPasses = 2; 862 if (numberNodes < 0) { 863 numberPasses = 5; 864 // Say some rows cuts 865 int numberRows = solver>getNumRows(); 866 if (numberNodes_ < numberRows && true /* think */) { 867 char * type = new char[numberRows]; 868 memset(type, 0, numberNodes_); 869 memset(type + numberNodes_, 1, numberRows  numberNodes_); 870 process.passInRowTypes(type, numberRows); 871 delete [] type; 872 } 873 } 874 if (logLevel <= 1) 875 process.messageHandler()>setLogLevel(0); 859 876 if (!solver>defaultHandler()&& 860 877 solver>messageHandler()>logLevel(0)!=1000) 861 878 process.passInMessageHandler(solver>messageHandler()); 862 OsiSolverInterface *solver2 = process.preProcessNonDefault(*solver, false,863 864 879 solver2 = process.preProcessNonDefault(*solver, false, 880 numberPasses); 881 if (!solver2) { 865 882 if (logLevel > 1) 866 883 printf("Preprocessing says infeasible\n"); 867 884 returnCode = 2; // so will be infeasible 868 885 } else { 869 886 #ifdef COIN_DEVELOP_z 870 887 if (numberNodes < 0) { 871 888 solver2>writeMpsNative("after2.mps", NULL, NULL, 2, 1); 872 889 } 873 890 #endif … … 899 916 // normal 900 917 model.setSpecialOptions(saveModelOptions  2048); 901 if (logLevel <= 1 )918 if (logLevel <= 1 && feasibilityPumpOptions_ != 3) 902 919 model.setLogLevel(0); 903 920 else … … 907 924 model.setCutoff(signedCutoff); 908 925 // Don't do if original fraction > 1.0 and too large 909 if (fractionSmall_>1.0 ) {926 if (fractionSmall_>1.0 && fractionSmall_ < 1000000.0) { 910 927 /* 1.4 means 1 nodes if >.4 911 928 2.4 means 1 nodes if >.5 and 0 otherwise … … 999 1016 #endif 1000 1017 model.setParentModel(*model_); 1001 model.setOriginalColumns(process.originalColumns()); 1018 model.setMaximumSolutions(model_>getMaximumSolutions()); 1019 model.setOriginalColumns(process.originalColumns()); 1002 1020 model.setSearchStrategy(1); 1003 1021 // If no feasibility pump then insert a lightweight one 1004 if (feasibilityPumpOptions_ >= 0 ) {1005 bool gotPump = false;1022 if (feasibilityPumpOptions_ >= 0  feasibilityPumpOptions_ == 2) { 1023 CbcHeuristicFPump * fpump = NULL; 1006 1024 for (int i = 0; i < model.numberHeuristics(); i++) { 1007 const CbcHeuristicFPump* pump = 1008 dynamic_cast<const CbcHeuristicFPump*>(model.heuristic(i)); 1009 if (pump) 1010 gotPump = true; 1025 CbcHeuristicFPump* pump = 1026 dynamic_cast<CbcHeuristicFPump*>(model.heuristic(i)); 1027 if (pump) { 1028 fpump = pump; 1029 break; 1030 } 1011 1031 } 1012 if (! gotPump) {1032 if (!fpump) { 1013 1033 CbcHeuristicFPump heuristic4; 1014 1034 // use any cutoff … … 1017 1037 heuristic4.setMaximumPasses(10); 1018 1038 int pumpTune = feasibilityPumpOptions_; 1039 if (pumpTune==2) 1040 pumpTune = 4; // proximity 1019 1041 if (pumpTune > 0) { 1020 1042 /* … … 1073 1095 } 1074 1096 model.addHeuristic(&heuristic4, "feasibility pump", 0); 1097 1075 1098 } 1076 } 1099 } else if (feasibilityPumpOptions_==3) { 1100 // add all (except this) 1101 for (int i = 0; i < model_>numberHeuristics(); i++) { 1102 if (strcmp(heuristicName(),model_>heuristic(i)>heuristicName())) 1103 model.addHeuristic(model_>heuristic(i)); 1104 } 1105 } 1077 1106 //printf("sol %x\n",inputSolution_); 1078 1107 if (inputSolution_) { … … 1169 1198 #define ALWAYS_DUAL 1170 1199 #ifdef ALWAYS_DUAL 1171 OsiSolverInterface * solver = model.solver();1200 OsiSolverInterface * solverD = model.solver(); 1172 1201 bool takeHint; 1173 1202 OsiHintStrength strength; 1174 solver >getHintParam(OsiDoDualInResolve, takeHint, strength);1175 solver >setHintParam(OsiDoDualInResolve, true, OsiHintDo);1203 solverD>getHintParam(OsiDoDualInResolve, takeHint, strength); 1204 solverD>setHintParam(OsiDoDualInResolve, true, OsiHintDo); 1176 1205 #endif 1177 1206 model.passInEventHandler(model_>getEventHandler()); … … 1182 1211 model_>setSpecialOptions(saveOptions); 1183 1212 #ifdef ALWAYS_DUAL 1184 solver = model.solver(); 1185 solver>setHintParam(OsiDoDualInResolve, takeHint, strength); 1186 #endif 1213 solverD = model.solver(); 1214 solverD>setHintParam(OsiDoDualInResolve, takeHint, strength); 1215 #endif 1216 numberNodesDone_ = model.getNodeCount(); 1187 1217 #ifdef COIN_DEVELOP 1188 1218 printf("sub branch %d nodes, %d iterations  max %d\n", … … 1238 1268 } 1239 1269 #endif 1240 process.postProcess(*model.solver()); 1270 //if (fractionSmall_ < 1000000.0) 1271 process.postProcess(*model.solver()); 1241 1272 if (solver>isProvenOptimal() && solver>getObjValue()*solver>getObjSense() < cutoff) { 1242 1273 // Solution now back in solver … … 1256 1287 process.numberIterationsPre() + 1257 1288 process.numberIterationsPost(); 1258 if (totalNumberIterations > 100*(numberNodes + 10)) { 1289 if (totalNumberIterations > 100*(numberNodes + 10) 1290 && fractionSmall_ < 1000000.0) { 1259 1291 // only allow smaller problems 1260 1292 fractionSmall = fractionSmall_; … … 1266 1298 } 1267 1299 if (model.status() == 5) 1268 returnCode = 2; // stop 1300 model_>sayEventHappened(); 1269 1301 if (model.isProvenInfeasible()) 1270 1302 status = 1;
Note: See TracChangeset
for help on using the changeset viewer.