 Timestamp:
 Aug 12, 2013 3:33:18 PM (8 years ago)
 Location:
 trunk/Cbc/src
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcHeuristicDW.cpp
r1953 r1955 595 595 const CoinBigIndex * columnStart = solver>getMatrixByCol()>getVectorStarts(); 596 596 const int * columnLength = solver>getMatrixByCol()>getVectorLengths(); 597 for (int i=0;i<numberBlocks_;i++) 598 whichBlock[i]=i; 597 int numberUsed=0; 599 598 for (int iBlock=0;iBlock<numberBlocks_;iBlock++) { 600 599 int start=startColumnBlock_[iBlock]; … … 607 606 columnsInBlock_+startColumnBlock_[iBlock]); 608 607 tempModel>setLogLevel(0); 608 tempModel>setDualObjectiveLimit(COIN_DBL_MAX); 609 609 double * objectiveX = tempModel>objective(); 610 610 double * columnLowerX = tempModel>columnLower(); … … 613 613 int jColumn=istart; 614 614 int iColumn=columnsInBlock_[i]; 615 columnLowerX[jColumn]= saveLower_[iColumn];616 columnUpperX[jColumn]= saveUpper_[iColumn];615 columnLowerX[jColumn]=CoinMax(saveLower_[iColumn],1.0e12); 616 columnUpperX[jColumn]=CoinMin(saveUpper_[iColumn],1.0e12); 617 617 if (solver>isInteger(iColumn)) 618 618 tempModel>setInteger(jColumn); … … 633 633 modelX.branchAndBound(); 634 634 const double * bestSolutionX = modelX.bestSolution(); 635 assert (bestSolutionX); 636 for (int i=start;i<end;i++) { 637 int jColumn = istart; 638 int iColumn=columnsInBlock_[i]; 639 bestSolution2[iColumn]=bestSolutionX[jColumn]; 640 } 641 } 642 addDW(bestSolution2,numberBlocks_,whichBlock); 635 if (bestSolutionX) { 636 whichBlock[numberUsed++]=iBlock; 637 for (int i=start;i<end;i++) { 638 int jColumn = istart; 639 int iColumn=columnsInBlock_[i]; 640 bestSolution2[iColumn]=bestSolutionX[jColumn]; 641 } 642 } 643 } 644 addDW(bestSolution2,numberUsed,whichBlock); 643 645 // now try purer DW 644 646 bool takeHint; … … 649 651 dwSolver_>setHintParam(OsiDoDualInResolve, takeHint, OsiHintDo); 650 652 duals = dwSolver_>getRowPrice(); 653 numberUsed=0; 651 654 for (int iBlock=0;iBlock<numberBlocks_;iBlock++) { 652 655 int start=startColumnBlock_[iBlock]; … … 659 662 columnsInBlock_+startColumnBlock_[iBlock]); 660 663 tempModel>setLogLevel(0); 664 tempModel>setDualObjectiveLimit(COIN_DBL_MAX); 661 665 double * objectiveX = tempModel>objective(); 662 666 double * columnLowerX = tempModel>columnLower(); … … 666 670 int jColumn=istart; 667 671 int iColumn=columnsInBlock_[i]; 668 columnLowerX[jColumn]= saveLower_[iColumn];672 columnLowerX[jColumn]=CoinMax(saveLower_[iColumn],1.0e12); 669 673 columnUpperX[jColumn]=CoinMin(saveUpper_[iColumn],1.0e12); 670 674 if (solver>isInteger(iColumn)) … … 691 695 iBlock,cObj,modelX.getObjValue(),convexityDual); 692 696 const double * bestSolutionX = modelX.bestSolution(); 693 assert (bestSolutionX); 694 for (int i=start;i<end;i++) { 695 int iColumn=columnsInBlock_[i]; 696 bestSolution2[iColumn]=bestSolutionX[istart]; 697 } 698 } 699 addDW(bestSolution2,numberBlocks_,whichBlock); 697 if (bestSolutionX) { 698 whichBlock[numberUsed++]=iBlock; 699 for (int i=start;i<end;i++) { 700 int iColumn=columnsInBlock_[i]; 701 bestSolution2[iColumn]=bestSolutionX[istart]; 702 } 703 } 704 } 705 addDW(bestSolution2,numberUsed,whichBlock); 700 706 delete [] bestSolution2; 701 707 } … … 2035 2041 tempModel>addRows(numberBlocks_,rhs,rhs,NULL,NULL,NULL); 2036 2042 delete [] rhs; 2037 dwSolver_ = new OsiClpSolverInterface(tempModel,true); 2043 OsiClpSolverInterface * clpSolver = new OsiClpSolverInterface(tempModel,true); 2044 clpSolver>getModelPtr()>setDualObjectiveLimit(COIN_DBL_MAX); 2045 dwSolver_ = clpSolver; 2038 2046 printf("DW model has %d master rows, %d master columns and %d convexity rows\n", 2039 2047 numberMasterRows,numberMasterColumns,numberBlocks_); 
trunk/Cbc/src/CbcHeuristicDW.hpp
r1951 r1955 146 146 { return whichColumnBlock_;} 147 147 /// Initial Lower bounds 148 inline constdouble * initialLower() const148 inline double * initialLower() const 149 149 { return saveLower_;} 150 150 /// Initial Upper bounds 151 inline constdouble * initialUpper() const151 inline double * initialUpper() const 152 152 { return saveUpper_;} 153 153 /// Local integer arrays (each numberBlocks_ long) 
trunk/Cbc/src/CbcHeuristicFPump.cpp
r1954 r1955 311 311 const double * upper = model_>solver()>getColUpper(); 312 312 bool doGeneral = (accumulate_ & 4) != 0; 313 int numberUnsatisfied=0; 314 double sumUnsatisfied=0.0; 315 const double * initialSolution = model_>solver()>getColSolution(); 313 316 j = 0; 314 317 /* … … 329 332 assert(integerObject  integerObject2); 330 333 #endif 334 double value = initialSolution[iColumn]; 335 double nearest = floor(value + 0.5); 336 sumUnsatisfied += fabs(value  nearest); 337 if (fabs(value  nearest) > 1.0e6) 338 numberUnsatisfied++; 331 339 if (upper[iColumn]  lower[iColumn] > 1.000001) { 332 340 general++; … … 368 376 printf("DOing general with %d out of %d\n", general, numberIntegers); 369 377 #endif 378 sprintf(pumpPrint, "Initial state  %d integers unsatisfied sum  %g", 379 numberUnsatisfied, sumUnsatisfied); 380 model_>messageHandler()>message(CBC_FPUMP1, model_>messages()) 381 << pumpPrint 382 << CoinMessageEol; 370 383 /* 371 384 This `closest solution' will satisfy integrality, but violate some other … … 576 589 // if cutoff exists then add constraint 577 590 bool useCutoff = (fabs(cutoff) < 1.0e20 && (fakeCutoff_ != COIN_DBL_MAX  numberTries > 1)); 591 bool tryOneClosePass=fakeCutoff_<solver>getObjValue(); 578 592 // but there may be a close one 579 593 if (firstCutoff < 2.0*solutionValue && numberTries == 1 && CoinMin(cutoff, fakeCutoff_) < 1.0e20) 580 594 useCutoff = true; 581 if (useCutoff ) {595 if (useCutoff  tryOneClosePass) { 582 596 double rhs = CoinMin(cutoff, fakeCutoff_); 597 if (tryOneClosePass) { 598 // If way off then .05 599 if (fakeCutoff_<=1.0e100) { 600 // use value as percentage  so 100==0.0, 101==1.0 etc 601 // probably something like pow I could use but ... 602 double fraction = 0.0; 603 while (fakeCutoff_<1.01e100) { 604 fakeCutoff_ *= 0.1; 605 fraction += 0.01; 606 } 607 rhs = solver>getObjValue()+fraction*fabs(solver>getObjValue()); 608 } else { 609 rhs = 2.0*solver>getObjValue()fakeCutoff_; // flip difference 610 } 611 fakeCutoff_=COIN_DBL_MAX; 612 } 583 613 const double * objective = solver>getObjCoefficients(); 584 614 int numberColumns = solver>getNumCols(); … … 1096 1126 int numberChanged = 0; 1097 1127 const double * oldObjective = solver>getObjCoefficients(); 1128 bool fixOnesAtBound=false; 1129 if (tryOneClosePass&&numberPasses==2) { 1130 // take off 1131 tryOneClosePass=false; 1132 int n=solver>getNumRows()1; 1133 double rhs = solver>getRowUpper()[n]; 1134 solver>setRowUpper(n,rhs+1.0e15); 1135 useRhs+=1.0e15; 1136 fixOnesAtBound=true; 1137 } 1098 1138 for (i = 0; i < numberColumns; i++) { 1099 1139 // below so we can keep original code and allow for objective … … 1115 1155 if (newSolution[iColumn] < lower[iColumn] + primalTolerance) { 1116 1156 newValue = costValue + scaleFactor * saveObjective[iColumn]; 1157 if (fixOnesAtBound) 1158 newValue = 100.0*costValue; 1117 1159 } else { 1118 1160 if (newSolution[iColumn] > upper[iColumn]  primalTolerance) { 1119 1161 newValue = costValue + scaleFactor * saveObjective[iColumn]; 1162 if (fixOnesAtBound) 1163 newValue = 100.0*costValue; 1120 1164 } 1121 1165 } 
trunk/Cbc/src/CbcSolverHeuristics.cpp
r1945 r1955 1296 1296 if (fakeIncrement) 1297 1297 increment = fakeIncrement; 1298 heuristic4.setAbsoluteIncrement(increment); 1298 if (increment>=0.0) 1299 heuristic4.setAbsoluteIncrement(increment); 1300 else 1301 heuristic4.setRelativeIncrement(increment); 1299 1302 heuristic4.setMaximumRetries(r + 1); 1300 1303 if (printStuff) { 1301 1304 if (increment) { 1302 sprintf(generalPrint, "Increment of %g", increment); 1305 if (increment>0.0) 1306 sprintf(generalPrint, "Absolute increment of %g", increment); 1307 else 1308 sprintf(generalPrint, "Relative increment of %g", increment); 1303 1309 generalMessageHandler>message(CBC_GENERAL, generalMessages) 1304 1310 << generalPrint
Note: See TracChangeset
for help on using the changeset viewer.