 Timestamp:
 Sep 25, 2006 2:22:16 PM (13 years ago)
 Location:
 branches/devel/Cbc/src
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

branches/devel/Cbc/src/CbcHeuristicFPump.cpp
r356 r435 120 120 121 121 int numberColumns = model_>getNumCols(); 122 char * usedColumn = NULL; 123 double * lastSolution=NULL; 124 bool fixContinuous=false; 125 bool fixInternal=false; 126 if (when_>=11&&when_<=13) { 127 fixInternal = when_ >11; 128 fixContinuous = when_==13; 129 when_=1; 130 usedColumn = new char [numberColumns]; 131 memset(usedColumn,0,numberColumns); 132 lastSolution = CoinCopyOfArray(solver>getColSolution(),numberColumns); 133 } 122 134 int numberIntegers = model_>numberIntegers(); 123 135 const int * integerVariable = model_>integerVariable(); … … 175 187 // 5. MAIN WHILE LOOP 176 188 int numberPasses=0; 189 double newSolutionValue=COIN_DBL_MAX; 177 190 bool newLineNeeded=false; 178 191 while (!finished) { 179 192 returnCode=0; 193 // see what changed 194 if (usedColumn) { 195 const double * solution = solver>getColSolution(); 196 for (i=0;i<numberColumns;i++) { 197 if (fabs(solution[i]lastSolution[i])>1.0e8) 198 usedColumn[i]=1; 199 lastSolution[i]=solution[i]; 200 } 201 } 180 202 if (numberPasses>=maximumPasses_) { 181 203 break; … … 194 216 // Compute using dot product 195 217 solver>setDblParam(OsiObjOffset,saveOffset); 196 doublenewSolutionValue = direction*solver>OsiSolverInterface::getObjValue();218 newSolutionValue = direction*solver>OsiSolverInterface::getObjValue(); 197 219 if (model_>logLevel()) 198 220 printf("  solution found\n"); … … 294 316 solver>resolve(); 295 317 if (model_>logLevel()) 296 printf("\npass %3d: obj. %10.5 lf > ", numberPasses,solver>getObjValue());318 printf("\npass %3d: obj. %10.5f > ", numberPasses,solver>getObjValue()); 297 319 newLineNeeded=true; 298 320 … … 302 324 printf("  no solution found\n"); 303 325 delete solver; 304 delete [] newSolution;305 326 for ( j=0;j<NUMBER_OLD;j++) 306 327 delete [] oldSolution[j]; 307 328 delete [] oldSolution; 308 329 delete [] saveObjective; 330 if (usedColumn) { 331 OsiSolverInterface * newSolver = model_>continuousSolver()>clone(); 332 const double * colLower = newSolver>getColLower(); 333 const double * colUpper = newSolver>getColUpper(); 334 int i; 335 int nFix=0; 336 int nFixI=0; 337 int nFixC=0; 338 for (i=0;i<numberIntegers;i++) { 339 int iColumn=integerVariable[i]; 340 const CbcObject * object = model_>object(i); 341 const CbcSimpleInteger * integerObject = 342 dynamic_cast<const CbcSimpleInteger *> (object); 343 assert(integerObject); 344 // get original bounds 345 double originalLower = integerObject>originalLowerBound(); 346 assert(colLower[iColumn]==originalLower); 347 newSolver>setColLower(iColumn,CoinMax(colLower[iColumn],originalLower)); 348 double originalUpper = integerObject>originalUpperBound(); 349 assert(colUpper[iColumn]==originalUpper); 350 newSolver>setColUpper(iColumn,CoinMin(colUpper[iColumn],originalUpper)); 351 if (!usedColumn[iColumn]) { 352 double value=lastSolution[iColumn]; 353 double nearest = floor(value+0.5); 354 if (fabs(valuenearest)<1.0e7) { 355 if (nearest==colLower[iColumn]) { 356 newSolver>setColUpper(iColumn,colLower[iColumn]); 357 nFix++; 358 } else if (nearest==colUpper[iColumn]) { 359 newSolver>setColLower(iColumn,colUpper[iColumn]); 360 nFix++; 361 } else if (fixInternal) { 362 newSolver>setColLower(iColumn,nearest); 363 newSolver>setColUpper(iColumn,nearest); 364 nFix++; 365 nFixI++; 366 } 367 } 368 } 369 } 370 if (fixContinuous) { 371 for (int iColumn=0;iColumn<numberColumns;iColumn++) { 372 if (!newSolver>isInteger(iColumn)&&!usedColumn[iColumn]) { 373 double value=lastSolution[iColumn]; 374 if (value<colLower[iColumn]+1.0e8) { 375 newSolver>setColUpper(iColumn,colLower[iColumn]); 376 nFix++; 377 nFixC++; 378 } else if (value>colUpper[iColumn]1.0e8) { 379 newSolver>setColLower(iColumn,colUpper[iColumn]); 380 nFix++; 381 nFixC++; 382 } 383 } 384 } 385 } 386 newSolver>initialSolve(); 387 assert (newSolver>isProvenOptimal()); 388 printf("%d integers at bound fixed, %d internal and %d continuous\n", 389 nFix,nFixI,nFixC); 390 double saveValue = newSolutionValue; 391 returnCode = smallBranchAndBound(newSolver,200,newSolution,newSolutionValue, 392 newSolutionValue,"CbcHeuristicLocalAfterFPump"); 393 if (returnCode) { 394 printf("old sol of %g new of %g\n",saveValue,newSolutionValue); 395 memcpy(betterSolution,newSolution,numberColumns*sizeof(double)); 396 solutionValue=newSolutionValue; 397 } 398 delete newSolver; 399 delete [] usedColumn; 400 delete [] lastSolution; 401 } 402 delete [] newSolution; 309 403 return returnCode; 310 404 } 
branches/devel/Cbc/src/CbcModel.cpp
r426 r435 6152 6152 if (!solverCharacteristics_>solutionAddsCuts()) { 6153 6153 // Can trust solution 6154 double cutoff = CoinMin(getCutoff(),bestObjective_) ; 6154 double cutoff = getCutoff(); 6155 if (cutoff<1.0e30) 6156 cutoff = CoinMin(cutoff,bestObjective_) ; 6155 6157 6156 6158 /* 
branches/devel/Cbc/src/CoinSolve.cpp
r427 r435 1525 1525 basisHasValues=1; 1526 1526 if (dualize) { 1527 ((ClpSimplexOther *) lpSolver)>restoreFromDual(model2);1527 int returnCode=((ClpSimplexOther *) lpSolver)>restoreFromDual(model2); 1528 1528 delete model2; 1529 if (returnCode) 1530 lpSolver>primal(1); 1529 1531 model2=lpSolver; 1530 1532 } … … 2055 2057 if (useFpump) { 2056 2058 heuristic4.setMaximumPasses(parameters[whichParam(FPUMPITS,numberParameters,parameters)].intValue()); 2059 if (doIdiot>10&&doIdiot<14) { 2060 heuristic4.setWhen(doIdiot); 2061 doIdiot=1; 2062 } 2057 2063 babModel>addHeuristic(&heuristic4); 2058 2064 } … … 2083 2089 if (probingAction==5) 2084 2090 probingGen.setRowCuts(3); // strengthening etc just at root 2091 if (probingAction==4) { 2092 // Number of unsatisfied variables to look at 2093 probingGen.setMaxProbe(1000); 2094 probingGen.setMaxProbeRoot(1000); 2095 // How far to follow the consequences 2096 probingGen.setMaxLook(50); 2097 probingGen.setMaxLookRoot(50); 2098 } 2085 2099 babModel>addCutGenerator(&probingGen,translate[probingAction],"Probing"); 2086 2100 switches[numberGenerators++]=0; … … 4495 4509 strcpy(line[numberLines++],"5 std::cout<<\"processed model has \"<<solver2>getNumRows()"); 4496 4510 strcpy(line[numberLines++],"5 <<\" rows, \"<<solver2>getNumCols()"); 4497 strcpy(line[numberLines++],"5 <<\" and \"<<solver2>getNumElements()<<std::endl;"); 4511 strcpy(line[numberLines++],"5 <<\" columns and \"<<solver2>getNumElements()"); 4512 strcpy(line[numberLines++],"5 <<\" elements\"<<solver2>getNumElements()<<std::endl;"); 4498 4513 strcpy(line[numberLines++],"5 }"); 4499 4514 strcpy(line[numberLines++],"5 // we have to keep solver2 so pass clone");
Note: See TracChangeset
for help on using the changeset viewer.