Changeset 1943 for trunk/Cbc/src/CbcHeuristic.cpp
 Timestamp:
 Jul 21, 2013 5:05:45 AM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcHeuristic.cpp
r1886 r1943 24 24 #include "CbcHeuristic.hpp" 25 25 #include "CbcHeuristicFPump.hpp" 26 #include "CbcEventHandler.hpp" 26 27 #include "CbcStrategy.hpp" 27 28 #include "CglPreProcess.hpp" … … 148 149 numberNodesDone_(0), 149 150 inputSolution_(NULL) 150 {} 151 { 152 } 151 153 152 154 void … … 407 409 if ((numCouldRun_ % howOften_) == 0 && 408 410 numberSolutionsFound_*howOften_ < numCouldRun_) { 411 //#define COIN_DEVELOP 409 412 #ifdef COIN_DEVELOP 410 413 int old = howOften_; … … 664 667 } 665 668 666 669 //static int saveModel=0; 667 670 // Do mini branch and bound (return 1 if solution) 668 671 int … … 671 674 double cutoff, std::string name) const 672 675 { 676 CbcEventHandler *eventHandler = model_>getEventHandler() ; 677 // Use this fraction 678 double fractionSmall = fractionSmall_; 679 int maximumSolutions = model_>getMaximumSolutions(); 680 int iterationMultiplier = 100; 681 if (eventHandler) { 682 typedef struct { 683 double fractionSmall; 684 double spareDouble[3]; 685 OsiSolverInterface * solver; 686 void * sparePointer[2]; 687 int numberNodes; 688 int maximumSolutions; 689 int iterationMultiplier; 690 int howOften; 691 int spareInt[3]; 692 } SmallMod; 693 SmallMod temp; 694 temp.solver=solver; 695 temp.fractionSmall=fractionSmall; 696 temp.numberNodes=numberNodes; 697 temp.iterationMultiplier=iterationMultiplier; 698 temp.howOften=howOften_; 699 temp.maximumSolutions=maximumSolutions; 700 CbcEventHandler::CbcAction status = 701 eventHandler>event(CbcEventHandler::smallBranchAndBound, 702 &temp); 703 if (status==CbcEventHandler::killSolution) 704 return 1; 705 if (status==CbcEventHandler::takeAction) { 706 fractionSmall=temp.fractionSmall; 707 numberNodes=temp.numberNodes; 708 iterationMultiplier=temp.iterationMultiplier; 709 howOften_=temp.howOften; 710 maximumSolutions=temp.maximumSolutions; 711 } 712 } 713 #if 0 714 if (saveModel  model_>getMaximumSolutions()==100) { 715 printf("writing model\n"); 716 solver>writeMpsNative("before.mps", NULL, NULL, 2, 1); 717 } 718 #endif 673 719 // size before 674 720 int shiftRows = 0; … … 681 727 name.c_str(), solver>getNumRows(), solver>getNumCols()); 682 728 #endif 683 // Use this fraction684 double fractionSmall = fractionSmall_;685 729 double before = 2 * numberRowsStart + numberColumnsStart; 686 730 if (before > 40000.0) { … … 729 773 //assert ((saveModelOptions&2048) == 0); 730 774 model_>setSpecialOptions(saveModelOptions  2048); 731 {775 if (fractionSmall<1.0) { 732 776 int saveLogLevel = solver>messageHandler()>logLevel(); 733 777 if (saveLogLevel == 1) … … 864 908 OsiSolverInterface * solver2 = NULL; 865 909 if ((model_>moreSpecialOptions()&65536)!=0) 866 process.setOptions(2+4+8); // no cuts 910 process.setOptions(2+4+8+16); // no cuts 911 else 912 process.setOptions(16); // no complicated dupcol stuff 867 913 /* Do not try and produce equality cliques and 868 914 do up to 2 passes (normally) 5 if restart */ 869 915 int numberPasses = 2; 916 if ((model_>moreSpecialOptions2()&16)!=0) { 917 // quick 918 process.setOptions(2+4+8+16); // no cuts 919 numberPasses = 1; 920 } 870 921 if (numberNodes < 0) { 871 922 numberPasses = 5; … … 956 1007 if ((saveModelOptions&2048) == 0) 957 1008 model.setMoreSpecialOptions(model_>moreSpecialOptions()); 1009 model.setMoreSpecialOptions2(model_>moreSpecialOptions2()); 958 1010 // off conflict analysis 959 1011 model.setMoreSpecialOptions(model.moreSpecialOptions()&~4194304); … … 1036 1088 #endif 1037 1089 model.setParentModel(*model_); 1038 model.setMaximumSolutions(m odel_>getMaximumSolutions());1090 model.setMaximumSolutions(maximumSolutions); 1039 1091 model.setOriginalColumns(process.originalColumns()); 1040 1092 model.setSearchStrategy(1); … … 1208 1260 setCutAndHeuristicOptions(model); 1209 1261 // not too many iterations 1210 model.setMaximumNumberIterations( 100*(numberNodes + 10));1262 model.setMaximumNumberIterations(iterationMultiplier*(numberNodes + 10)); 1211 1263 // Not fast stuff 1212 1264 model.setFastNodeDepth(1); … … 1228 1280 int saveOptions = model_>specialOptions(); 1229 1281 model_>setSpecialOptions(saveOptions1048576); 1282 // and switch off debugger 1283 model.setSpecialOptions(model.specialOptions()&(~1)); 1284 #if 0 //def COIN_HAS_CLP 1285 OsiClpSolverInterface * clpSolver 1286 = dynamic_cast<OsiClpSolverInterface *> (model.solver()); 1287 if (clpSolver) 1288 clpSolver>zapDebugger(); 1289 #endif 1230 1290 model.branchAndBound(); 1231 1291 model_>setHeuristicModel(NULL); … … 1333 1393 } else { 1334 1394 returnCode = 2; // infeasible finished 1395 printf("Infeasible on initial solve\n"); 1335 1396 } 1336 1397 model_>setSpecialOptions(saveModelOptions); … … 1808 1869 double primalTolerance; 1809 1870 solver>getDblParam(OsiPrimalTolerance, primalTolerance); 1871 double useTolerance = primalTolerance; 1810 1872 1811 1873 int numberRows = matrix_.getNumRows(); … … 1866 1928 int iColumn = integerVariable[i]; 1867 1929 double value = newSolution[iColumn]; 1930 double thisTolerance = integerTolerance; 1868 1931 if (fabs(floor(value + 0.5)  value) > integerTolerance) { 1869 1932 double below = floor(value); … … 1935 1998 double thisCost = direction * objective[iColumn] * distance; 1936 1999 if (integerType[iColumn]) { 1937 distance = ceil(distance  primalTolerance);1938 if (currentValue  distance >= lowerValue  primalTolerance) {1939 if (absInfeasibility  distance*absElement < gap  primalTolerance)2000 distance = ceil(distance  useTolerance); 2001 if (currentValue  distance >= lowerValue  useTolerance) { 2002 if (absInfeasibility  distance*absElement < gap  useTolerance) 1940 2003 thisCost = 1.0e100; // no good 1941 2004 else … … 1961 2024 if (integerType[iColumn]) { 1962 2025 distance = ceil(distance  1.0e7); 1963 assert (currentValue  distance <= upperValue + primalTolerance);1964 if (absInfeasibility  distance*absElement < gap  primalTolerance)2026 assert (currentValue  distance <= upperValue + useTolerance); 2027 if (absInfeasibility  distance*absElement < gap  useTolerance) 1965 2028 thisCost = 1.0e100; // no good 1966 2029 else … … 2139 2202 // and now all if improving 2140 2203 double lastChange = penaltyChange ? 1.0 : 0.0; 2141 while (lastChange > 1.0e2) { 2204 int numberPasses=0; 2205 while (lastChange > 1.0e2 && numberPasses < 1000) { 2142 2206 lastChange = 0; 2207 numberPasses++; 2143 2208 for (iColumn = 0; iColumn < numberColumns; iColumn++) { 2144 2209 bool isInteger = (integerType[iColumn] != 0); … … 2355 2420 bool good = true; 2356 2421 double newValue = newSolution[iColumn] + move; 2357 if (newValue < lower[iColumn]  primalTolerance 2358 newValue > upper[iColumn] + primalTolerance) {2422 if (newValue < lower[iColumn]  useTolerance  2423 newValue > upper[iColumn] + useTolerance) { 2359 2424 move = 0.0; 2360 2425 } else {
Note: See TracChangeset
for help on using the changeset viewer.