Changeset 1499 for trunk/Cbc/src/CbcHeuristicRENS.cpp
 Timestamp:
 Aug 31, 2010 7:14:51 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcHeuristicRENS.cpp
r1432 r1499 13 13 #include "CbcMessage.hpp" 14 14 #include "CbcHeuristicRENS.hpp" 15 #include "CoinWarmStartBasis.hpp" 15 16 #include "CbcBranchActual.hpp" 16 17 #include "CbcStrategy.hpp" … … 22 23 { 23 24 numberTries_ = 0; 25 rensType_ = 0; 24 26 whereFrom_ = 256 + 1; 25 27 } … … 31 33 { 32 34 numberTries_ = 0; 35 rensType_ = 0; 33 36 whereFrom_ = 256 + 1; 34 37 } … … 53 56 CbcHeuristic::operator=(rhs); 54 57 numberTries_ = rhs.numberTries_; 58 rensType_ = rhs.rensType_; 55 59 } 56 60 return *this; … … 61 65 : 62 66 CbcHeuristic(rhs), 63 numberTries_(rhs.numberTries_) 67 numberTries_(rhs.numberTries_), 68 rensType_(rhs.rensType_) 64 69 { 65 70 } … … 75 80 int returnCode = 0; 76 81 const double * bestSolution = model_>bestSolution(); 77 if ( numberTries_ (when() < 2 && bestSolution))82 if ((numberTries_&&(rensType_&16)==0)  numberTries_>1  (when() < 2 && bestSolution)) 78 83 return 0; 79 84 numberTries_++; … … 84 89 85 90 const double * currentSolution = solver>getColSolution(); 91 const double * dj = solver>getReducedCost(); 86 92 OsiSolverInterface * newSolver = cloneBut(3); // was model_>continuousSolver()>clone(); 93 int numberColumns = newSolver>getNumCols(); 94 double direction = newSolver>getObjSense(); 95 int type = rensType_&15; 96 double djTolerance = (type!=1) ? 1.0e30 : 1.0e4; 87 97 const double * colLower = newSolver>getColLower(); 88 98 const double * colUpper = newSolver>getColUpper(); 99 if ((type&3)==3) { 100 double total=0.0; 101 int n=0; 102 CoinWarmStartBasis * basis = 103 dynamic_cast<CoinWarmStartBasis *>(solver>getWarmStart()) ; 104 if (basis) { 105 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 106 if (colUpper[iColumn]>colLower[iColumn]&& 107 basis>getStructStatus(iColumn) != 108 CoinWarmStartBasis::basic) { 109 n++; 110 total += fabs(dj[iColumn]); 111 } 112 } 113 if (n) 114 djTolerance = (0.01*total)/static_cast<double>(n); 115 delete basis; 116 } 117 } 89 118 90 119 double primalTolerance; … … 95 124 int numberTightened = 0; 96 125 int numberAtBound = 0; 97 int numberColumns = newSolver>getNumCols();98 126 int numberContinuous = numberColumns  numberIntegers; 99 127 … … 105 133 value = CoinMax(value, lower); 106 134 value = CoinMin(value, upper); 135 double djValue=dj[iColumn]*direction; 107 136 #define RENS_FIX_ONLY_LOWER 108 137 #ifndef RENS_FIX_ONLY_LOWER … … 121 150 #else 122 151 if (fabs(value  floor(value + 0.5)) < 1.0e8 && 123 floor(value + 0.5) == lower) { 124 value = floor(value + 0.5); 125 numberAtBound++; 126 newSolver>setColLower(iColumn, value); 127 newSolver>setColUpper(iColumn, value); 128 numberFixed++; 129 } else if (colUpper[iColumn]  colLower[iColumn] >= 2.0) { 152 floor(value + 0.5) == lower && 153 djValue > djTolerance ) { 154 value = floor(value + 0.5); 155 numberAtBound++; 156 newSolver>setColLower(iColumn, value); 157 newSolver>setColUpper(iColumn, value); 158 numberFixed++; 159 } else if (fabs(value  floor(value + 0.5)) < 1.0e8 && 160 floor(value + 0.5) == upper && 161 djValue > djTolerance && (djTolerance > 0.0type==2)) { 162 value = floor(value + 0.5); 163 numberAtBound++; 164 newSolver>setColLower(iColumn, value); 165 newSolver>setColUpper(iColumn, value); 166 numberFixed++; 167 } else if (colUpper[iColumn]  colLower[iColumn] >= 2.0 && 168 djTolerance <0.0) { 130 169 numberTightened++; 131 170 if (fabs(value  floor(value + 0.5)) < 1.0e8) { … … 145 184 } 146 185 if (numberFixed > numberIntegers / 5) { 147 if ( numberContinuous > numberIntegers &&numberFixed < numberColumns / 5) {186 if ( numberFixed < numberColumns / 5) { 148 187 #define RENS_FIX_CONTINUOUS 149 188 #ifdef RENS_FIX_CONTINUOUS … … 153 192 double sumDj = 0.0; 154 193 const double * dj = newSolver>getReducedCost(); 155 double direction = newSolver>getObjSense();156 194 for (int iColumn = 0; iColumn < numberColumns; iColumn++) { 157 195 if (!newSolver>isInteger(iColumn)) {
Note: See TracChangeset
for help on using the changeset viewer.