Changeset 502 for branches/devel/Cbc/src/CbcHeuristic.cpp
 Timestamp:
 Dec 18, 2006 9:39:29 AM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/devel/Cbc/src/CbcHeuristic.cpp
r439 r502 25 25 CbcHeuristic::CbcHeuristic() 26 26 :model_(NULL), 27 when_(2) 28 { 27 when_(2), 28 numberNodes_(200), 29 fractionSmall_(1.0) 30 { 31 // As CbcHeuristic virtual need to modify .cpp if above change 29 32 } 30 33 … … 33 36 : 34 37 model_(&model), 35 when_(2) 36 { 37 } 38 when_(2), 39 numberNodes_(200), 40 fractionSmall_(1.0) 41 { 42 // As CbcHeuristic virtual need to modify .cpp if above change 43 } 44 // Copy constructor 45 CbcHeuristic::CbcHeuristic(const CbcHeuristic & rhs) 46 : 47 model_(rhs.model_), 48 when_(rhs.when_), 49 numberNodes_(rhs.numberNodes_), 50 fractionSmall_(rhs.fractionSmall_) 51 { 52 } 53 // Assignment operator 54 CbcHeuristic & 55 CbcHeuristic::operator=( const CbcHeuristic& rhs) 56 { 57 if (this!=&rhs) { 58 model_ = rhs.model_; 59 when_ = rhs.when_; 60 numberNodes_ = rhs.numberNodes_; 61 fractionSmall_ = rhs.fractionSmall_; 62 } 63 return *this; 64 } 65 38 66 // Resets stuff if model changes 39 67 void … … 43 71 } 44 72 73 // Create C++ lines to get to current state 74 void 75 CbcHeuristic::generateCpp( FILE * fp, const char * heuristic) 76 { 77 // hard coded as CbcHeuristic virtual 78 if (when_!=2) 79 fprintf(fp,"3 %s.setWhen(%d);\n",heuristic,when_); 80 else 81 fprintf(fp,"4 %s.setWhen(%d);\n",heuristic,when_); 82 if (numberNodes_!=200) 83 fprintf(fp,"3 %s.setNumberNodes(%d);\n",heuristic,numberNodes_); 84 else 85 fprintf(fp,"4 %s.setNumberNodes(%d);\n",heuristic,numberNodes_); 86 if (fractionSmall_!=1.0) 87 fprintf(fp,"3 %s.setFractionSmall(%g);\n",heuristic,fractionSmall_); 88 else 89 fprintf(fp,"4 %s.setFractionSmall(%g);\n",heuristic,fractionSmall_); 90 } 45 91 // Destructor 46 92 CbcHeuristic::~CbcHeuristic () … … 90 136 if (logLevel>1) 91 137 printf("Preprocessing says infeasible\n"); 92 returnCode= 0; // so will be infeasible138 returnCode=2; // so will be infeasible 93 139 } else { 140 // see if too big 141 double before = solver>getNumRows()+solver>getNumCols(); 142 double after = solver2>getNumRows()+solver2>getNumCols(); 143 printf("before %d rows %d columns, after %d rows %d columns\n", 144 solver>getNumRows(),solver>getNumCols(), 145 solver2>getNumRows(),solver2>getNumCols()); 146 if (after>fractionSmall_*before) 147 return 0; 94 148 solver2>resolve(); 95 149 CbcModel model(*solver2); … … 120 174 if (model.getMinimizationObjValue()<CoinMin(cutoff,1.0e30)) { 121 175 // solution 122 returnCode= 1;176 returnCode=model.isProvenOptimal() ? 3 : 1; 123 177 // post process 124 178 process.postProcess(*model.solver()); … … 135 189 } else { 136 190 // no good 137 returnCode= 0; // so will be infeasible191 returnCode=model.isProvenInfeasible() ? 2 : 0; // so will be infeasible 138 192 } 139 193 } 140 194 } else { 141 returnCode= 0;195 returnCode=2; // infeasible finished 142 196 } 143 197 return returnCode; … … 181 235 fprintf(fp,"0#include \"CbcHeuristic.hpp\"\n"); 182 236 fprintf(fp,"3 CbcRounding rounding(*cbcModel);\n"); 237 CbcHeuristic::generateCpp(fp,"rounding"); 183 238 if (seed_!=other.seed_) 184 239 fprintf(fp,"3 rounding.setSeed(%d);\n",seed_); … … 196 251 seed_(rhs.seed_) 197 252 { 198 setWhen(rhs.when()); 253 } 254 255 // Assignment operator 256 CbcRounding & 257 CbcRounding::operator=( const CbcRounding& rhs) 258 { 259 if (this!=&rhs) { 260 CbcHeuristic::operator=(rhs); 261 matrix_ = rhs.matrix_; 262 matrixByRow_ = rhs.matrixByRow_; 263 seed_ = rhs.seed_; 264 } 265 return *this; 199 266 } 200 267 … … 907 974 fprintf(fp,"0#include \"CbcHeuristic.hpp\"\n"); 908 975 fprintf(fp,"3 CbcSerendipity serendipity(*cbcModel);\n"); 976 CbcHeuristic::generateCpp(fp,"serendipity"); 909 977 fprintf(fp,"3 cbcModel>addHeuristic(&serendipity);\n"); 910 978 } … … 915 983 CbcHeuristic(rhs) 916 984 { 985 } 986 987 // Assignment operator 988 CbcSerendipity & 989 CbcSerendipity::operator=( const CbcSerendipity& rhs) 990 { 991 if (this!=&rhs) { 992 CbcHeuristic::operator=(rhs); 993 } 994 return *this; 917 995 } 918 996
Note: See TracChangeset
for help on using the changeset viewer.