Changeset 1837 for stable/2.7/Cbc/src/CbcHeuristic.cpp
 Timestamp:
 Dec 22, 2012 11:17:37 AM (9 years ago)
 Location:
 stable/2.7/Cbc
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

stable/2.7/Cbc
 Property svn:mergeinfo changed
/releases/2.7.8/Cbc (added) merged: 1834
 Property svn:mergeinfo changed

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