Changes from stable/2.9/Cbc/src/CbcCutGenerator.cpp at r2174 to trunk/Cbc/src/CbcCutGenerator.cpp at r2105
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcCutGenerator.cpp
r2174 r2105 430 430 printf("On optimal path CbcCut\n"); 431 431 int nCols = solver>getNumCols(); 432 int i; 432 433 const double * optimal = debugger>optimalSolution(); 433 434 const double * objective = solver>getObjCoefficients(); 434 435 double objval1 = 0.0, objval2 = 0.0; 435 for (int i = 0; i < nCols; i++) { 436 if (!solver>isInteger(i)) 437 continue; 436 for (i = 0; i < nCols; i++) { 438 437 #if CGL_DEBUG>1 439 438 printf("%d %g %g %g %g\n", i, lower[i], solution[i], upper[i], optimal[i]); … … 617 616 const OsiRowCutDebugger * debugger = solver>getRowCutDebugger(); 618 617 #endif 619 //#define WEAKEN_CUTS 1620 #ifdef WEAKEN_CUTS621 const double * lower = solver>getColLower();622 const double * upper = solver>getColUpper();623 const double * solution = solver>getColSolution();624 #endif625 618 for (k = numberRowCutsBefore; k < numberRowCutsAfter; k++) { 626 619 OsiRowCut * thisCut = cs.rowCutPtr(k) ; 627 #ifdef WEAKEN_CUTS628 // weaken cut if coefficients not integer629 double lb=thisCut>lb();630 double ub=thisCut>ub();631 if (lb<1.0e100ub>1.0e100) {632 // normal cut633 CoinPackedVector rpv = thisCut>row();634 const int n = rpv.getNumElements();635 const int * indices = rpv.getIndices();636 const double * elements = rpv.getElements();637 double bound=0.0;638 double sum=0.0;639 bool integral=true;640 int nInteger=0;641 for (int k=0; k<n; k++) {642 double value = fabs(elements[k]);643 int column=indices[k];644 sum += value;645 if (value!=floor(value+0.5))646 integral=false;647 if (solver>isInteger(column)) {648 nInteger++;649 double largerBound = CoinMax(fabs(lower[column]),650 fabs(upper[column]));651 double solutionBound=fabs(solution[column])+10.0;652 bound += CoinMin(largerBound,solutionBound);653 }654 }655 #if WEAKEN_CUTS ==1656 // leave if all 01657 if (nInteger==bound)658 integral=true;659 #elif WEAKEN_CUTS==4WEAKEN_CUTS==5660 // leave if all 01661 if (nInteger==bound && n < 40)662 integral=true;663 #endif664 if (!integral) {665 double weakenBy=1.0e7*(bound+sum);666 #if WEAKEN_CUTS==3WEAKEN_CUTS==5667 weakenBy *= 10.0;668 #endif669 if (lb<1.0e100)670 thisCut>setUb(ub+weakenBy);671 else672 thisCut>setLb(lbweakenBy);673 }674 }675 #endif676 620 #ifdef CGL_DEBUG 677 621 if (debugger && debugger>onOptimalPath(*solver)) { 678 if(debugger>invalidCut(*thisCut)) { 622 assert(!debugger>invalidCut(*thisCut)); 623 if(debugger>invalidCut(*thisCut)) 679 624 abort(); 680 }681 625 } 682 626 #endif
Note: See TracChangeset
for help on using the changeset viewer.