Changeset 1048 for stable/2.2/Cbc/src/CbcSolver.cpp
 Timestamp:
 Aug 20, 2008 3:17:05 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

stable/2.2/Cbc/src/CbcSolver.cpp
r1030 r1048 3621 3621 CbcModel * babModel_ = NULL; 3622 3622 int returnMode=1; 3623 CbcOrClpRead_mode=1; 3623 3624 int statusUserFunction_[1]; 3624 3625 int numberUserFunctions_=1; // to allow for ampl … … 6606 6607 CbcSimpleInteger * obj = 6607 6608 dynamic_cast <CbcSimpleInteger *>(oldObjects[iObj]) ; 6608 assert (obj); 6609 obj>setColumnNumber(iColumn); 6609 if (obj) { 6610 obj>setColumnNumber(iColumn); 6611 } else { 6612 // only other case allowed is lotsizing 6613 CbcLotsize * obj2 = 6614 dynamic_cast <CbcLotsize *>(oldObjects[iObj]) ; 6615 assert (obj2); 6616 obj2>setModelSequence(iColumn); 6617 } 6610 6618 oldObjects[n++]=oldObjects[iObj]; 6611 6619 } else { … … 7668 7676 bestSolution = new double [n]; 7669 7677 OsiClpSolverInterface * clpSolver = dynamic_cast< OsiClpSolverInterface*> (babModel_>solver()); 7678 // Save bounds on processed model 7679 const int * originalColumns = process.originalColumns(); 7680 int numberColumns2 = clpSolver>getNumCols(); 7681 double * solution2 = new double[n]; 7682 double * lower2 = new double [n]; 7683 double * upper2 = new double [n]; 7684 for (int i=0;i<n;i++) { 7685 solution2[i]=COIN_DBL_MAX; 7686 lower2[i]=COIN_DBL_MAX; 7687 upper2[i]=COIN_DBL_MAX; 7688 } 7689 const double *columnLower = clpSolver>getColLower() ; 7690 const double * columnUpper = clpSolver>getColUpper() ; 7691 const double * solution = babModel_>bestSolution(); 7692 for (int i=0;i<numberColumns2;i++) { 7693 int jColumn = originalColumns[i]; 7694 solution2[jColumn]=solution[i]; 7695 lower2[jColumn]=columnLower[i]; 7696 upper2[jColumn]=columnUpper[i]; 7697 } 7670 7698 ClpSimplex * lpSolver = clpSolver>getModelPtr(); 7671 7699 lpSolver>setSpecialOptions(lpSolver>specialOptions()IN_BRANCH_AND_BOUND); // say is Cbc (and in branch and bound) 7672 7700 process.postProcess(*babModel_>solver()); 7673 7701 // Solution now back in saveSolver 7702 // Double check bounds 7703 columnLower = saveSolver>getColLower() ; 7704 columnUpper = saveSolver>getColUpper() ; 7705 solution = saveSolver>getColSolution(); 7706 int numberChanged=0; 7707 for (int i=0;i<n;i++) { 7708 if (lower2[i]!=COIN_DBL_MAX) { 7709 if (lower2[i]!=columnLower[i] 7710 upper2[i]!=columnUpper[i]) { 7711 if (lower2[i]<columnLower[i] 7712 upper2[i]>columnUpper[i]) { 7713 #ifdef COIN_DEVELOP 7714 printf("odd bounds tighter"); 7715 printf("%d bab bounds %g %g now %g %g\n", 7716 i,lower2[i],upper2[i],columnLower[i], 7717 columnUpper[i]); 7718 #endif 7719 } else { 7720 #ifdef COIN_DEVELOP 7721 printf("%d bab bounds %g %g now %g %g\n", 7722 i,lower2[i],upper2[i],columnLower[i], 7723 columnUpper[i]); 7724 #endif 7725 numberChanged++; 7726 saveSolver>setColLower(i,lower2[i]); 7727 saveSolver>setColUpper(i,upper2[i]); 7728 } 7729 } 7730 } 7731 } 7732 delete [] solution2; 7733 delete [] lower2; 7734 delete [] upper2; 7735 if (numberChanged) { 7736 sprintf(generalPrint,"%d bounds tightened after postprocessing\n", 7737 numberChanged); 7738 generalMessageHandler>message(CLP_GENERAL,generalMessages) 7739 << generalPrint 7740 <<CoinMessageEol; 7741 saveSolver>resolve(); 7742 assert (saveSolver>isProvenOptimal()); 7743 } 7744 #if NEW_STYLE_SOLVER==0 7745 // and original solver 7746 assert (n==originalSolver>getNumCols()); 7747 originalSolver>setColLower(saveSolver>getColLower()); 7748 originalSolver>setColUpper(saveSolver>getColUpper()); 7749 // basis 7750 CoinWarmStartBasis * basis = dynamic_cast<CoinWarmStartBasis *> (babModel_>solver()>getWarmStart()); 7751 originalSolver>setBasis(*basis); 7752 delete basis; 7753 originalSolver>resolve(); 7754 assert (originalSolver>isProvenOptimal()); 7755 #endif 7674 7756 babModel_>assignSolver(saveSolver); 7675 7757 memcpy(bestSolution,babModel_>solver()>getColSolution(),n*sizeof(double)); … … 7704 7786 originalSolver>setBasis(*basis); 7705 7787 delete basis; 7788 originalSolver>resolve(); 7789 assert (originalSolver>isProvenOptimal()); 7706 7790 } 7707 7791 #endif
Note: See TracChangeset
for help on using the changeset viewer.