 Timestamp:
 Mar 24, 2015 5:57:18 AM (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

stable/2.9/Cbc/src/CbcCutGenerator.cpp
r2105 r2174 430 430 printf("On optimal path CbcCut\n"); 431 431 int nCols = solver>getNumCols(); 432 int i;433 432 const double * optimal = debugger>optimalSolution(); 434 433 const double * objective = solver>getObjCoefficients(); 435 434 double objval1 = 0.0, objval2 = 0.0; 436 for (i = 0; i < nCols; i++) { 435 for (int i = 0; i < nCols; i++) { 436 if (!solver>isInteger(i)) 437 continue; 437 438 #if CGL_DEBUG>1 438 439 printf("%d %g %g %g %g\n", i, lower[i], solution[i], upper[i], optimal[i]); … … 616 617 const OsiRowCutDebugger * debugger = solver>getRowCutDebugger(); 617 618 #endif 619 //#define WEAKEN_CUTS 1 620 #ifdef WEAKEN_CUTS 621 const double * lower = solver>getColLower(); 622 const double * upper = solver>getColUpper(); 623 const double * solution = solver>getColSolution(); 624 #endif 618 625 for (k = numberRowCutsBefore; k < numberRowCutsAfter; k++) { 619 626 OsiRowCut * thisCut = cs.rowCutPtr(k) ; 627 #ifdef WEAKEN_CUTS 628 // weaken cut if coefficients not integer 629 double lb=thisCut>lb(); 630 double ub=thisCut>ub(); 631 if (lb<1.0e100ub>1.0e100) { 632 // normal cut 633 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 ==1 656 // leave if all 01 657 if (nInteger==bound) 658 integral=true; 659 #elif WEAKEN_CUTS==4WEAKEN_CUTS==5 660 // leave if all 01 661 if (nInteger==bound && n < 40) 662 integral=true; 663 #endif 664 if (!integral) { 665 double weakenBy=1.0e7*(bound+sum); 666 #if WEAKEN_CUTS==3WEAKEN_CUTS==5 667 weakenBy *= 10.0; 668 #endif 669 if (lb<1.0e100) 670 thisCut>setUb(ub+weakenBy); 671 else 672 thisCut>setLb(lbweakenBy); 673 } 674 } 675 #endif 620 676 #ifdef CGL_DEBUG 621 677 if (debugger && debugger>onOptimalPath(*solver)) { 622 assert(!debugger>invalidCut(*thisCut)); 623 if(debugger>invalidCut(*thisCut)) 678 if(debugger>invalidCut(*thisCut)) { 624 679 abort(); 680 } 625 681 } 626 682 #endif
Note: See TracChangeset
for help on using the changeset viewer.