Changeset 147 for trunk/Samples/sample2.cpp
 Timestamp:
 Jun 8, 2005 12:13:14 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Samples/sample2.cpp
r117 r147 17 17 #include "CbcCutGenerator.hpp" 18 18 #include "CbcHeuristicUser.hpp" 19 #ifdef COIN_USE_CLP20 19 #include "OsiClpSolverInterface.hpp" 21 #endif22 #ifdef COIN_USE_OSL23 #include "OsiOslSolverInterface.hpp"24 #endif25 20 26 21 // Cuts … … 32 27 #include "CglClique.hpp" 33 28 #include "CglFlowCover.hpp" 34 #include "CglMixedIntegerRounding .hpp"29 #include "CglMixedIntegerRounding2.hpp" 35 30 // Preprocessing 36 31 #include "CglPreProcess.hpp" … … 73 68 // Define your favorite OsiSolver 74 69 75 #ifdef COIN_USE_CLP76 70 OsiClpSolverInterface solver1; 77 #elif COIN_USE_OSL78 OsiOslSolverInterface solver1;79 #endif80 71 81 72 // Read in model using argv[1] … … 142 133 CglProbing generator1; 143 134 generator1.setUsingObjective(true); 144 generator1.setMaxPass(3); 135 generator1.setMaxPass(1); 136 generator1.setMaxPassRoot(5); 145 137 // Number of unsatisfied variables to look at 146 138 generator1.setMaxProbe(10); 139 generator1.setMaxProbeRoot(1000); 147 140 // How far to follow the consequences 148 141 generator1.setMaxLook(50); 142 generator1.setMaxLookRoot(500); 149 143 // Only look at rows with fewer than this number of elements 150 144 generator1.setMaxElements(200); … … 168 162 generator5.setRowCliqueReport(false); 169 163 170 CglMixedIntegerRounding mixedGen;164 CglMixedIntegerRounding2 mixedGen; 171 165 CglFlowCover flowGen; 172 166 … … 187 181 generator>setTiming(true); 188 182 } 189 #ifdef COIN_USE_CLP190 183 OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver()); 191 184 // go faster stripes 192 185 if (osiclp>getNumRows()<300&&osiclp>getNumCols()<500) { 193 186 osiclp>setupForRepeatedUse(2,0); 194 printf("trying slightly less reliable but faster version (? Gomory cuts okay?)\n"); 195 printf("may not be safe if doing cuts in tree which need accuracy (level 2 anyway)\n"); 196 } 197 #endif 198 187 } 188 model.messagesPointer()>setDetailMessage(0,61); 199 189 // Allow rounding heuristic 200 190 … … 219 209 220 210 // Could tune more 221 model.setMinimumDrop(min(1.0, 222 fabs(model.getMinimizationObjValue())*1.0e3+1.0e4)); 211 double objValue = model.solver()>getObjSense()*model.solver()>getObjValue(); 212 double minimumDropA=CoinMin(1.0,fabs(objValue)*1.0e3+1.0e4); 213 double minimumDrop= fabs(objValue)*1.0e4+1.0e4; 214 printf("min drop %g (A %g)\n",minimumDrop,minimumDropA); 215 model.setMinimumDrop(minimumDrop); 223 216 224 217 if (model.getNumCols()<500) … … 228 221 else 229 222 model.setMaximumCutPassesAtRoot(20); 230 //model.setMaximumCutPasses(5); 223 model.setMaximumCutPasses(10); 224 //model.setMaximumCutPasses(2); 231 225 232 226 // Switch off strong branching if wanted … … 235 229 if (model.getNumCols()<5000) 236 230 model.setNumberStrong(10); 231 model.setNumberStrong(20); 237 232 238 233 model.solver()>setIntParam(OsiMaxNumIterationHotStart,100); … … 254 249 //model.solver()>messageHandler()>setLogLevel(2); 255 250 //model.setPrintFrequency(50); 251 //#define DEBUG_CUTS 256 252 #ifdef DEBUG_CUTS 257 253 // Set up debugger by name (only if no preprocesing) … … 288 284 std::cout<<std::endl; 289 285 } 290 // Print solution if finished  we can't get names from Osi! 286 // Print solution if finished  we can't get names from Osi!  so get from OsiClp 291 287 292 288 if (model.getMinimizationObjValue()<1.0e50) { … … 303 299 304 300 const double * solution = solver>getColSolution(); 301 302 // Get names from solver1 (as OsiSolverInterface may lose) 303 std::vector<std::string> columnNames = *solver1.getModelPtr()>columnNames(); 305 304 306 305 int iColumn; … … 311 310 double value=solution[iColumn]; 312 311 if (fabs(value)>1.0e7&&solver>isInteger(iColumn)) 313 std::cout<<std::setw(6)<<iColumn<<" "<<value<<std::endl; 312 std::cout<<std::setw(6)<<iColumn<<" " 313 <<columnNames[iColumn]<<" " 314 <<value<<std::endl; 314 315 } 315 316 std::cout<<""<<std::endl;
Note: See TracChangeset
for help on using the changeset viewer.