Changeset 1876
 Timestamp:
 Mar 19, 2013 9:04:43 AM (9 years ago)
 Location:
 trunk/Cbc/src
 Files:

 5 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcHeuristicGreedy.cpp
r1796 r1876 398 398 399 399 int numberRows = solver>getNumRows(); 400 int numberColumns = solver>getNumCols(); 400 401 // Column copy 402 matrix_.setDimensions(numberRows,numberColumns); 401 403 const double * element = matrix_.getElements(); 402 404 const CoinBigIndex * columnStart = matrix_.getVectorStarts(); … … 407 409 good = false; 408 410 } 409 int numberColumns = solver>getNumCols();410 411 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 411 412 if (objective[iColumn]*direction < 0.0) … … 830 831 831 832 int numberRows = solver>getNumRows(); 833 int numberColumns = solver>getNumCols(); 834 matrix_.setDimensions(numberRows,numberColumns); 832 835 // Column copy 833 836 const double * element = matrix_.getElements(); … … 843 846 good = false; 844 847 } 845 int numberColumns = solver>getNumCols();846 848 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 847 849 if (objective[iColumn]*direction < 0.0) 
trunk/Cbc/src/CbcLinked.cpp
r1854 r1876 330 330 } 331 331 modelPtr_>replaceMatrix(temp, true); 332 modelPtr_>setNewRowCopy(NULL); 333 modelPtr_>setClpScaledMatrix(NULL); 332 334 } else { 333 335 delete temp; 
trunk/Cbc/src/CbcModel.cpp
r1867 r1876 2153 2153 handler_>message(CBC_HEURISTICS_OFF, messages_) << numberOdd << CoinMessageEol ; 2154 2154 } 2155 // If odd switch off AddIntegers 2156 specialOptions_ &= ~65536; 2155 2157 } else if (numberSOS) { 2156 2158 specialOptions_ = 128; // say can do SOS in dynamic mode … … 3695 3697 Decide if we want to do a restart. 3696 3698 */ 3697 if (saveSolver ) {3699 if (saveSolver && (specialOptions_&(512 + 32768)) != 0) { 3698 3700 bool tryNewSearch = solverCharacteristics_>reducedCostsAccurate() && 3699 3701 (getCutoff() < 1.0e20 && getCutoff() < checkCutoffForRestart); … … 14066 14068 // Set original columns as created by preprocessing 14067 14069 void 14068 CbcModel::setOriginalColumns(const int * originalColumns )14070 CbcModel::setOriginalColumns(const int * originalColumns,int numberGood) 14069 14071 { 14070 14072 int numberColumns = getNumCols(); 14071 14073 delete [] originalColumns_; 14072 originalColumns_ = CoinCopyOfArray(originalColumns, numberColumns); 14074 originalColumns_ = new int [numberColumns]; 14075 int numberCopy=CoinMin(numberColumns,numberGood); 14076 memcpy(originalColumns_,originalColumns,numberCopy*sizeof(int)); 14077 for (int i=numberCopy;i<numberColumns;i++) 14078 originalColumns_[i]=1; 14073 14079 } 14074 14080 // Set the cut modifier method 
trunk/Cbc/src/CbcModel.hpp
r1839 r1876 866 866 } 867 867 /// Set original columns as created by preprocessing 868 void setOriginalColumns(const int * originalColumns) ; 868 void setOriginalColumns(const int * originalColumns, 869 int numberGood=COIN_INT_MAX) ; 869 870 870 871 /** Set the print frequency. 
trunk/Cbc/src/CbcSolver.cpp
r1864 r1876 178 178 #include "CglKnapsackCover.hpp" 179 179 #include "CglRedSplit.hpp" 180 #include "CglRedSplit2.hpp" 181 #include "CglGMI.hpp" 180 182 #include "CglClique.hpp" 181 183 #include "CglFlowCover.hpp" … … 644 646 parameters_[whichParam(CBC_PARAM_STR_ZEROHALFCUTS, numberParameters_, parameters_)].setCurrentOption("off"); 645 647 parameters_[whichParam(CBC_PARAM_STR_REDSPLITCUTS, numberParameters_, parameters_)].setCurrentOption("off"); 648 parameters_[whichParam(CBC_PARAM_STR_REDSPLIT2CUTS, numberParameters_, parameters_)].setCurrentOption("off"); 649 parameters_[whichParam(CBC_PARAM_STR_GMICUTS, numberParameters_, parameters_)].setCurrentOption("off"); 646 650 parameters_[whichParam(CBC_PARAM_STR_CLIQUECUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); 647 651 parameters_[whichParam(CBC_PARAM_STR_MIXEDCUTS, numberParameters_, parameters_)].setCurrentOption("ifmove"); … … 1581 1585 int redsplitAction = 0; 1582 1586 1587 CglRedSplit2 redsplit2Gen; 1588 //redsplit2Gen.setLimit(100); 1589 // set default action (0=off,1=on,2=root) 1590 // Off 1591 int redsplit2Action = 0; 1592 1593 CglGMI GMIGen; 1594 //GMIGen.setLimit(100); 1595 // set default action (0=off,1=on,2=root) 1596 // Off 1597 int GMIAction = 0; 1598 1583 1599 CglFakeClique cliqueGen(NULL, false); 1584 1600 //CglClique cliqueGen(false,true); … … 1636 1652 int doKKT = 0; 1637 1653 int crossover = 2; // do crossover unless quadratic 1654 bool biLinearProblem=false; 1638 1655 // For names 1639 1656 int lengthName = 0; … … 1794 1811 model_.setDblParam(CbcModel::CbcStartSeconds, CoinCpuTime()); 1795 1812 #endif 1813 biLinearProblem=false; 1796 1814 // check if any integers 1797 1815 #ifndef CBC_OTHER_SOLVER … … 2339 2357 redsplitAction = action; 2340 2358 break; 2359 case CBC_PARAM_STR_REDSPLIT2CUTS: 2360 defaultSettings = false; // user knows what she is doing 2361 redsplit2Action = action; 2362 break; 2363 case CBC_PARAM_STR_GMICUTS: 2364 defaultSettings = false; // user knows what she is doing 2365 GMIAction = action; 2366 break; 2341 2367 case CBC_PARAM_STR_CLIQUECUTS: 2342 2368 defaultSettings = false; // user knows what she is doing … … 2400 2426 redsplitAction = action; 2401 2427 parameters_[whichParam(CBC_PARAM_STR_REDSPLITCUTS, numberParameters_, parameters_)].setCurrentOption(action); 2428 redsplit2Action = action; 2429 parameters_[whichParam(CBC_PARAM_STR_REDSPLIT2CUTS, numberParameters_, parameters_)].setCurrentOption(action); 2430 GMIAction = action; 2431 parameters_[whichParam(CBC_PARAM_STR_GMICUTS, numberParameters_, parameters_)].setCurrentOption(action); 2402 2432 landpAction = action; 2403 2433 parameters_[whichParam(CBC_PARAM_STR_LANDPCUTS, numberParameters_, parameters_)].setCurrentOption(action); … … 3082 3112 bool miplib = type == CBC_PARAM_ACTION_MIPLIB; 3083 3113 int logLevel = parameters_[slog].intValue(); 3114 int truncateColumns=COIN_INT_MAX; 3115 int * newPriorities=NULL; 3084 3116 // Reduce printout 3085 3117 if (logLevel <= 1) { … … 3140 3172 si>setIntegerPriority(1000); 3141 3173 si>setBiLinearPriority(10000); 3174 biLinearProblem=true; 3142 3175 si>setSpecialOptions2(2 + 4 + 8); 3143 3176 CoinModel * model2 = coinModel; … … 3902 3935 // we have to keep solver2 so pass clone 3903 3936 solver2 = solver2>clone(); 3937 // see if extra variables wanted 3938 int threshold = 3939 parameters_[whichParam(CBC_PARAM_INT_EXTRA_VARIABLES, numberParameters_, parameters_)].intValue(); 3940 if (threshold) { 3941 int numberColumns = solver2>getNumCols(); 3942 int highPriority=0; 3943 /* 3944 normal  no priorities 3945 >10000 equal high priority 3946 >20000 higher priority for higher cost 3947 */ 3948 if (threshold>10000) { 3949 highPriority=threshold/10000; 3950 threshold = 10000*highPriority; 3951 } 3952 const double * columnLower = solver2>getColLower(); 3953 const double * columnUpper = solver2>getColUpper(); 3954 const double * objective = solver2>getObjCoefficients(); 3955 int numberIntegers = 0; 3956 int numberBinary = 0; 3957 int numberTotalIntegers=0; 3958 double * obj = new double [numberColumns]; 3959 int * which = new int [numberColumns]; 3960 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 3961 if (solver2>isInteger(iColumn)) { 3962 numberTotalIntegers++; 3963 if (columnUpper[iColumn] > columnLower[iColumn]) { 3964 numberIntegers++; 3965 if (columnLower[iColumn] == 0.0 && columnUpper[iColumn] == 1) 3966 numberBinary++; 3967 } 3968 } 3969 } 3970 int numberSort=0; 3971 int numberZero=0; 3972 int numberZeroContinuous=0; 3973 int numberDifferentObj=0; 3974 int numberContinuous=0; 3975 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 3976 if (columnUpper[iColumn] > columnLower[iColumn]) { 3977 if (solver2>isInteger(iColumn)) { 3978 if (!objective[iColumn]) { 3979 numberZero++; 3980 } else { 3981 obj[numberSort]= fabs(objective[iColumn]); 3982 which[numberSort++]=iColumn; 3983 } 3984 } else if (objective[iColumn]) { 3985 numberContinuous++; 3986 } else { 3987 numberZeroContinuous++; 3988 } 3989 } 3990 } 3991 CoinSort_2(obj,obj+numberSort,which); 3992 double last=obj[0]; 3993 for (int jColumn = 1; jColumn < numberSort; jColumn++) { 3994 if (fabs(obj[jColumn]last)>1.0e12) { 3995 numberDifferentObj++; 3996 last=obj[jColumn]; 3997 } 3998 } 3999 numberDifferentObj++; 4000 sprintf(generalPrint,"Problem has %d integers (%d of which binary) and %d continuous", 4001 numberIntegers,numberBinary,numberColumnsnumberIntegers); 4002 generalMessageHandler>message(CLP_GENERAL, generalMessages) 4003 << generalPrint 4004 << CoinMessageEol; 4005 if (numberColumns>numberIntegers) { 4006 sprintf(generalPrint,"%d continuous have nonzero objective, %d have zero objective", 4007 numberContinuous,numberZeroContinuous); 4008 generalMessageHandler>message(CLP_GENERAL, generalMessages) 4009 << generalPrint 4010 << CoinMessageEol; 4011 } 4012 sprintf(generalPrint,"%d integer have nonzero objective, %d have zero objective, %d different nonzero (taking abs)", 4013 numberSort,numberZero,numberDifferentObj); 4014 generalMessageHandler>message(CLP_GENERAL, generalMessages) 4015 << generalPrint 4016 << CoinMessageEol; 4017 if (numberDifferentObj<=threshold + (numberZero) ? 1 : 0 && numberDifferentObj) { 4018 int * backward=NULL; 4019 if (highPriority) { 4020 newPriorities = new int [numberTotalIntegers+numberDifferentObj+numberColumns]; 4021 backward=newPriorities+numberTotalIntegers+numberDifferentObj; 4022 numberTotalIntegers=0; 4023 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 4024 if (solver2>isInteger(iColumn)) { 4025 backward[iColumn]=numberTotalIntegers; 4026 newPriorities[numberTotalIntegers++]=10000; 4027 } 4028 } 4029 } 4030 int iLast=0; 4031 double last=obj[0]; 4032 for (int jColumn = 1; jColumn < numberSort; jColumn++) { 4033 if (fabs(obj[jColumn]last)>1.0e12) { 4034 sprintf(generalPrint,"%d variables have objective of %g", 4035 jColumniLast,last); 4036 generalMessageHandler>message(CLP_GENERAL, generalMessages) 4037 << generalPrint 4038 << CoinMessageEol; 4039 iLast=jColumn; 4040 last=obj[jColumn]; 4041 } 4042 } 4043 sprintf(generalPrint,"%d variables have objective of %g", 4044 numberSortiLast,last); 4045 generalMessageHandler>message(CLP_GENERAL, generalMessages) 4046 << generalPrint 4047 << CoinMessageEol; 4048 int spaceNeeded=numberSort+numberDifferentObj; 4049 int * columnAdd = new int[spaceNeeded+numberDifferentObj+1]; 4050 double * elementAdd = new double[spaceNeeded]; 4051 int * rowAdd = new int[numberDifferentObj+1]; 4052 double * objectiveNew = new double[3*numberDifferentObj]; 4053 double * lowerNew = objectiveNew+numberDifferentObj; 4054 double * upperNew = lowerNew+numberDifferentObj; 4055 memset(columnAdd+spaceNeeded,0, 4056 (numberDifferentObj+1)*sizeof(int)); 4057 iLast=0; 4058 last=obj[0]; 4059 numberDifferentObj=0; 4060 int priorityLevel=9999; 4061 int numberElements=0; 4062 rowAdd[0]=0; 4063 for (int jColumn = 1; jColumn < numberSort+1; jColumn++) { 4064 if (jColumn==numberSortfabs(obj[jColumn]last)>1.0e12) { 4065 // not if just one 4066 if (jColumniLast>1) { 4067 // do priority 4068 if (highPriority==1) { 4069 newPriorities[numberTotalIntegers+numberDifferentObj] 4070 = 500; 4071 } else if (highPriority==2) { 4072 newPriorities[numberTotalIntegers+numberDifferentObj] 4073 = priorityLevel; 4074 priorityLevel; 4075 } 4076 int iColumn=which[iLast]; 4077 objectiveNew[numberDifferentObj]=objective[iColumn]; 4078 double lower=0.0; 4079 double upper=0.0; 4080 for (int kColumn=iLast;kColumn<jColumn;kColumn++) { 4081 iColumn=which[kColumn]; 4082 solver2>setObjCoeff(iColumn,0.0); 4083 double lowerValue=columnLower[iColumn]; 4084 double upperValue=columnUpper[iColumn]; 4085 double elementValue=1.0; 4086 if (objectiveNew[numberDifferentObj]*objective[iColumn]<0.0) { 4087 lowerValue=columnUpper[iColumn]; 4088 upperValue=columnLower[iColumn]; 4089 elementValue=1.0; 4090 } 4091 columnAdd[numberElements]=iColumn; 4092 elementAdd[numberElements++]=elementValue; 4093 if (lower!=COIN_DBL_MAX) { 4094 if (lowerValue!=COIN_DBL_MAX) 4095 lower += lowerValue; 4096 else 4097 lower=COIN_DBL_MAX; 4098 } 4099 if (upper!=COIN_DBL_MAX) { 4100 if (upperValue!=COIN_DBL_MAX) 4101 upper += upperValue; 4102 else 4103 upper=COIN_DBL_MAX; 4104 } 4105 } 4106 columnAdd[numberElements]=numberColumns+numberDifferentObj; 4107 elementAdd[numberElements++]=1.0; 4108 lowerNew[numberDifferentObj]=lower; 4109 upperNew[numberDifferentObj]=upper; 4110 numberDifferentObj++; 4111 rowAdd[numberDifferentObj]=numberElements; 4112 } else if (highPriority) { 4113 // just one 4114 // do priority 4115 int iColumn=which[iLast]; 4116 int iInt=backward[iColumn]; 4117 if (highPriority==1) { 4118 newPriorities[iInt] = 500; 4119 } else { 4120 newPriorities[iInt] = priorityLevel; 4121 priorityLevel; 4122 } 4123 } 4124 if (jColumn<numberSort) { 4125 iLast=jColumn; 4126 last=obj[jColumn]; 4127 } 4128 } 4129 } 4130 if (numberDifferentObj) { 4131 // add columns 4132 solver2>addCols(numberDifferentObj, 4133 columnAdd+spaceNeeded, NULL, NULL, 4134 lowerNew, upperNew,objectiveNew); 4135 // add constraints and make integer if all integer in group 4136 for (int iObj=0; iObj < numberDifferentObj; iObj++) { 4137 lowerNew[iObj]=0.0; 4138 upperNew[iObj]=0.0; 4139 solver2>setInteger(numberColumns+iObj); 4140 } 4141 solver2>addRows(numberDifferentObj, 4142 rowAdd,columnAdd,elementAdd, 4143 lowerNew, upperNew); 4144 sprintf(generalPrint,"Replacing model  %d new variables",numberDifferentObj); 4145 generalMessageHandler>message(CLP_GENERAL, generalMessages) 4146 << generalPrint 4147 << CoinMessageEol; 4148 truncateColumns=numberColumns; 4149 } 4150 delete [] columnAdd; 4151 delete [] elementAdd; 4152 delete [] rowAdd; 4153 delete [] objectiveNew; 4154 } 4155 delete [] which; 4156 delete [] obj; 4157 } 3904 4158 babModel_>assignSolver(solver2); 3905 babModel_>setOriginalColumns(process.originalColumns()); 4159 babModel_>setOriginalColumns(process.originalColumns(), 4160 truncateColumns); 3906 4161 babModel_>initialSolve(); 3907 4162 babModel_>setMaximumSeconds(timeLeft  (CoinCpuTime()  time2)); … … 4041 4296 priority[iPut] = level; 4042 4297 } 4298 if(newPriorities ) { 4299 // get rid of 4300 delete [] newPriorities; 4301 newPriorities = NULL; 4302 } 4043 4303 babModel_>passInPriorities( priority, false); 4044 4304 integersOK = true; … … 4205 4465 switches[numberGenerators++] = 1; 4206 4466 } 4467 if (redsplit2Action && !complicatedInteger) { 4468 int maxLength=256; 4469 if (redsplit2Action>2) { 4470 redsplit2Action=2; 4471 maxLength=COIN_INT_MAX; 4472 } 4473 CglRedSplit2Param & parameters = redsplit2Gen.getParam(); 4474 parameters.setMaxNonzeroesTab(maxLength); 4475 babModel_>addCutGenerator(&redsplit2Gen, translate[redsplit2Action], "Reduceandsplit(2)"); 4476 accuracyFlag[numberGenerators] = 5; 4477 switches[numberGenerators++] = 1; 4478 } 4479 if (GMIAction && !complicatedInteger) { 4480 if (GMIAction>5) { 4481 // long 4482 GMIAction=5; 4483 CglGMIParam & parameters = GMIGen.getParam(); 4484 parameters.setMaxSupportRel(1.0); 4485 } 4486 babModel_>addCutGenerator(&GMIGen, translate[GMIAction], "Gomory(2)"); 4487 if (GMIAction==5) { 4488 // just at end and root 4489 GMIAction=2; 4490 doAtEnd[numberGenerators]=1; 4491 } 4492 accuracyFlag[numberGenerators] = 5; 4493 switches[numberGenerators++] = 0; 4494 } 4207 4495 if (cliqueAction) { 4208 4496 babModel_>addCutGenerator(&cliqueGen, translate[cliqueAction], "Clique"); … … 4572 4860 prioritiesIn2[i] = 1000000; 4573 4861 } 4862 #ifndef NDEBUG 4574 4863 int iLast = 1; 4864 #endif 4575 4865 for (i = 0; i < numberColumns; i++) { 4576 4866 int iColumn = originalColumns[i]; 4867 #ifndef NDEBUG 4577 4868 assert (iColumn > iLast); 4578 4869 iLast = iColumn; 4870 #endif 4579 4871 solutionIn2[i] = solutionIn2[iColumn]; 4580 4872 if (prioritiesIn) … … 4627 4919 for (i = 0; i < numberOriginalColumns; i++) 4628 4920 newColumn[i] = 1; 4629 for (i = 0; i < numberColumns; i++)4921 for (i = 0; i < CoinMin(truncateColumns,numberColumns); i++) 4630 4922 newColumn[originalColumns[i]] = i; 4631 4923 if (!integersOK) { … … 5216 5508 babModel_>setBranchingMethod(decision); 5217 5509 if (useCosts && testOsiOptions >= 0) { 5510 if(newPriorities ) { 5511 // get rid of 5512 delete [] newPriorities; 5513 newPriorities = NULL; 5514 } 5218 5515 int numberColumns = babModel_>getNumCols(); 5219 5516 int * sort = new int[numberColumns]; … … 5626 5923 donor.setStoredRowCuts(NULL); 5627 5924 } 5925 // We may have priorities from extra variables 5926 if(newPriorities ) { 5927 if (truncateColumns<babModel_>getNumCols()) { 5928 // set new ones as high prority 5929 babModel_>passInPriorities(newPriorities,false); 5930 } 5931 delete [] newPriorities; 5932 } 5628 5933 #ifdef JJF_ZERO 5629 5934 int extra5 = parameters_[whichParam(EXTRA5, numberParameters_, parameters_)].intValue(); … … 5648 5953 if (specialOptions>=0) 5649 5954 babModel_>setStrongStrategy(specialOptions); 5955 if (biLinearProblem) 5956 babModel_>setSpecialOptions(babModel_>specialOptions() &(~(51232768))); 5650 5957 babModel_>branchAndBound(statistics); 5958 if (truncateColumns<babModel_>solver()>getNumCols()) { 5959 OsiSolverInterface * solverX = babModel_>solver(); 5960 int numberColumns=solverX>getNumCols(); 5961 int numberRows=solverX>getNumRows(); 5962 int numberDelete = numberColumnstruncateColumns; 5963 int * delStuff=new int [numberDelete]; 5964 for (int i=0;i<numberDelete;i++) 5965 delStuff[i]=i+truncateColumns; 5966 solverX>deleteCols(numberDelete,delStuff); 5967 for (int i=0;i<numberDelete;i++) 5968 delStuff[i]=i+numberRowsnumberDelete; 5969 solverX>deleteRows(numberDelete,delStuff); 5970 delete [] delStuff; 5971 } 5651 5972 //#define CLP_FACTORIZATION_INSTRUMENT 5652 5973 #ifdef CLP_FACTORIZATION_INSTRUMENT … … 8805 9126 parameters[whichParam(CBC_PARAM_STR_ZEROHALFCUTS, numberParameters, parameters)].setCurrentOption("off"); 8806 9127 parameters[whichParam(CBC_PARAM_STR_REDSPLITCUTS, numberParameters, parameters)].setCurrentOption("off"); 9128 parameters[whichParam(CBC_PARAM_STR_REDSPLIT2CUTS, numberParameters, parameters)].setCurrentOption("off"); 9129 parameters[whichParam(CBC_PARAM_STR_GMICUTS, numberParameters, parameters)].setCurrentOption("off"); 8807 9130 parameters[whichParam(CBC_PARAM_STR_CLIQUECUTS, numberParameters, parameters)].setCurrentOption("ifmove"); 8808 9131 parameters[whichParam(CBC_PARAM_STR_MIXEDCUTS, numberParameters, parameters)].setCurrentOption("ifmove");
Note: See TracChangeset
for help on using the changeset viewer.