Changeset 961


Ignore:
Timestamp:
Jan 15, 2011 9:33:21 PM (11 years ago)
Author:
lou
Message:

(nonworking) Rewrite strengthenCoeff. Different case analysis to make earlier
decisions about goodness of cut.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CglWorking101215/src/CglProbing/CglProbingProbe.cpp

    r960 r961  
    749749  Generate coefficient strengthening cuts.
    750750 
    751   Assume we have a binary probe variable x<p> with a<ip> > 0. This will
    752   be a down probe, so assume that U<i> > b<i> before the probe, but now
    753   U'<i> < b<i> (i.e., the constraint is redundant against b<i> after the
    754   down probe forces x<p> to 0 and reduces U<i> to U'<i>). We would like to
    755   have the following:
    756     * When x<p> = 0, b'<i> = U'<i>  (after all, the lhs can't be any larger)
     751  Assume we have a binary probe variable x<p> with a<ip> > 0. Assume a
     752  down probe.  Assume that U<i> > b<i> before the probe, but now U'<i> < b<i>
     753  (i.e., the constraint is redundant against b<i> after the down probe forces
     754  x<p> to 0 and reduces U<i> to U'<i>). We would like to have the following in
     755  a strengthened constraint a'<ip>x<p> + (stuff) <= b'<i>:
     756    * When x<p> = 0, b'<i> = U'<i>  (the lhs can't be larger than U'<i>)
    757757    * When x<p> = 1, b'<i> = b<i>   (the original value)
    758   Define delta<i> = b<i> - U'<i>. Let b'<i> = b<i>-delta<i> and let
    759   a'<ip> = a<ip>-delta<i>. Then when x<p> = 1, the delta<i> on each side
    760   cancels and we're left with the original constraint. When x<p> = 0, the rhs
    761   becomes b'<i> = b<i>+delta<i> = U'<i>.
    762 
    763   The usual case analysis applies; see the typeset documentation. It's not
    764   necessarily true that U'<i> = U<i> - a<ip>u<p>; additional propagation could
    765   have reduced it even further. That doesn't alter the reasoning above.
    766 
    767   TODO: Figure out why goingToTrueBound is relevant here, other than it's
    768         set to zero if we're infeasible.  -- lh, 101127 --
    769 
    770         I think that might be all there is to it.   -- lh, 101128 --
    771 
    772         Well, maybe not. Check the math for the contained cuts to see if
    773         it's valid only for binary variables; when within distance 1 of
    774         the upper or lower bound of a general integer; or more generally.
    775         GoingToTrueBound indicates the first of these two. -- lh, 110105 --
    776 
    777         After working the math a few times, it looks to me like the important
    778         aspect is that goingToTrueBound = 2 indicates binary variables. I
    779         can't get the math to agree with the code otherwise. See the problem
    780         noted below. I'm going to restrict this method to binary variables
    781         until I can resolve questions about general integers.  -- lh, 110113 --
     758  Define delta = b<i> - U'<i>, b'<i> = b<i>-delta, and  a'<ip> = a<ip>-delta.
     759  When x<p> = 1, the delta term on each side cancels and we're left with the
     760  original constraint. When x<p> = 0, the rhs tightens to
     761  b'<i> = b<i>+delta<i> = U'<i>.
     762
     763  For an honest derivation that works for binary and general integer
     764  variables, see the typeset documentation. As you'd expect, there are four
     765  cases (a<ip> < 0, a<ip> > 0) X (up probe, down probe). Assume that a down
     766  probe bounds x<p> as [l<p>, u'<p>] and an up probe bounds x<p> as [l'<p>,
     767  u<p>]. Then the summary (omitting subscripts to fit the line) is:
     768
     769  a<ip>  dir    delta             blow'       a'<ip>      b'
     770
     771    >0    d    b - U'                         a-delta   b-(u'+1)delta
     772    >0    u    blow - L'   blow+(l'-1)delta   a+delta
     773    <0    d    b - L'      blow-(u'+1)delta   a-delta
     774    <0    u    blow - U'                      a+delta   b+(l'-1)delta
     775
     776  In the code, negating delta for down probes unifies the up and down math.
     777
     778  TODO: In the original code, this method will not execute if column cuts
     779        are present (i.e., bounds were tightened so that some x*<j> may not
     780        be feasible). The current code retains those guards.  Clearly it's
     781        a problem if x*<p> isn't feasible --- we can't generate a useful
     782        cut over floor(x*<p>), ceil(x*<p>) if the interval is outside the
     783        polytope. It's not so clear this is an obstacle for other variables,
     784        except that the lhs activity may be inaccurate.
    782785*/
    783786
    784787#define STRENGTHEN_PRINT
    785788void strengthenCoeff (
    786                       int jProbe,
     789                      int jProbe, unsigned int probeDir,
    787790                      double primalTolerance_,
    788791                      bool justReplace, bool canReplace,
     
    806809# if CGL_DEBUG > 0
    807810  std::cout
    808     << "Entering strengthenCoeff, probed variable "
    809     << si.getColName(jProbe) << "(" << jProbe << ")." << std::endl ;
     811    << "Entering strengthenCoeff, probing "
     812    << si.getColName(jProbe) << "(" << jProbe << ") "
     813    << ((probeDir == probeDown)?"down":"up") << "." << std::endl ;
    810814  const OsiRowCutDebugger *debugger = si.getRowCutDebugger() ;
    811815# endif
     816/*
     817  Define magic numbers up front.
     818    * Limits on `reasonable' coefficients. We don't want coefficients
     819      outside this range.
     820    * `Infinity' for the rhs. This'll get fixed later.
     821    * Effectiveness in the case that a<ip> = 0 and a'<ip> != 0.
     822  All copied from the original code.
     823*/
     824  const double bigCoeff = 1.0e8 ;
     825  const double tinyCoeff = 1.0e-12 ;
     826  const double rhsInf = 1.0e20 ;
     827  const double aipZeroEffectiveness = 1.0e-7 ;
    812828/*
    813829  Unpack a few vectors from the row-major matrix.
     
    821837  for (int istackR = 0 ; istackR < nstackR ; istackR++) {
    822838    int irow = stackR[istackR] ;
     839    double bi = rowUpper[irow] ;
     840    double blowi = rowLower[irow] ;
    823841/*
    824842  We can't get anywhere unless probing has made one end or the other of the
    825   constraint redundant.
    826 
    827   Really, we shouldn't be here if b<i> or blow<i> are not finite. Check with
    828   an assert.
    829 */
    830     double uGap = rowUpper[irow]-maxR[irow] ;
    831     assert(uGap < 1.0e8) ;
    832     double lGap = minR[irow]-rowLower[irow] ;
    833     assert(lGap < 1.0e8) ;
    834     if (uGap < primalTolerance_ && lGap < primalTolerance_) continue ;
    835 /*
    836   We'll need the lhs activity to evaluate the effectiveness of the cut. Do a
    837   base calculation which we'll correct later.
    838  
    839   TODO: Sort out why anyColumnCuts is an obstacle. Theoretical or practical?
    840         Could we use the new bound instead?  -- lh, 101128 --
    841 
    842         After working the math, looks to me like the only effect will be where
    843         a column cut cuts off the current solution, in which case the lhs
    844         value (sum) may be incorrect, affecting the calculation of
    845         effectiveness. We could correct for this, if it was worth the effort
    846         (a max or min when calculating the sum below). -- lh, 110113 --
     843  constraint redundant. If there's no gap, we can't do anything.
     844*/
     845    double uGap = bi-maxR[irow] ;
     846    double lGap = blowi-minR[irow] ;
     847    if (uGap < primalTolerance_ && -lGap < primalTolerance_) continue ;
     848    bool isRangeCon = ((blowi  > -rhsInf) && (bi < rhsInf)) ;
     849/*
     850  We'll need the lhs activity, excluding the probed variable, to evaluate the
     851  effectiveness of the cut.  Extract the coefficient of the probe variable
     852  while we're here; we need it to determine which case we're working.
     853
     854  TODO: As noted at the head of the routine, we could correct for column cuts
     855        by checking bounds when calculating the sum below, if it was worth the
     856        effort.   -- lh, 110113 --
    847857*/
    848858    double sum = 0.0 ;
    849     for (int kk = rowStart[irow] ; kk < rowStart[irow+1] ; kk++) {
    850       sum += rowElements[kk]*colsol[column[kk]] ;
     859    double aip = 0.0 ;
     860    bool aipNonZero = false ;
     861    for (CoinBigIndex kk = rowStart[irow] ; kk < rowStart[irow+1] ; kk++) {
     862      int k = column[kk] ;
     863      double aik = rowElements[kk] ;
     864      if (k == jProbe) {
     865        aipNonZero = true ;
     866        aip = aik ;
     867      } else {
     868        sum += aik*colsol[k] ;
     869      }
    851870    }
    852871/*
    853   Start out by working against the row upper bound U(i).  We've calculated
    854   sum using the current a<ik>, so reduce it by (-a<ip>+a'<ip>)x*<p> =
    855   (-uGap)(x*<p>) to do the check.
    856 
    857   We're not willing to generate a cut if it doesn't cut off the current
    858   solution, but we are willing to strengthen the existing constraint in place.
    859   Can't hurt, eh? Excluding range constraints in this case avoids the issue
    860   of conflicting a'<ij> if it turns out we can strengthen against b<i>
    861   and blow<i> in the same constraint.
    862 */
    863     if (uGap > primalTolerance_ &&
    864         (sum-uGap*colsol[jProbe] > maxR[irow]+primalTolerance_ ||
    865          (info->strengthenRow && rowLower[irow] < -1.0e20))) {
    866 /*
    867   Generate the coefficients. For all except the probing variable, we just copy
    868   the coefficient. The probing variable becomes a'<ij> = (a<ij> - uGap). Allow
    869   for the possibility that a<ij> starts or ends as 0.
    870 
    871   TODO: The value of sum2 calculated here should be precisely
    872         sum-uGap*colsol[j], unless my math is way wrong.  -- lh, 110107 --
    873 */
    874       int n = 0 ;
    875       bool saw_aip = false ;
    876       double sum2 = 0.0 ;
    877       for (int kk = rowStart[irow] ; kk < rowStart[irow+1] ; kk++) {
    878         int kColumn = column[kk] ;
    879         double el = rowElements[kk] ;
    880         if (kColumn != jProbe) {
    881           index[n] = kColumn ;
    882           element[n++] = el ;
    883         } else {
    884           el = el-uGap ;
    885           if (fabs(el) > 1.0e-12) {
    886             index[n] = kColumn ;
    887             element[n++] = el ;
    888           }
    889           saw_aip = true ;
    890         }
    891         sum2 += colsol[kColumn]*el ;
     872  Now figure out which case we're in and do some setup. At the end, see if the
     873  coefficient will have reasonable magnitude. If not, move on to the next
     874  iteration.
     875*/
     876    double delta ;
     877    double deltaMul ;
     878    bool revisebi = true ;
     879    if (probeDir == probeDown) {
     880      deltaMul = colUpper[jProbe]+1.0 ;
     881      if (aip >= 0) {
     882        delta = -uGap ;
     883      } else {
     884        delta = -lGap ;
     885        revisebi = false ;
    892886      }
    893       if (!saw_aip) {
    894         index[n] = jProbe ;
    895         element[n++] = -uGap ;
    896         sum2 -= colsol[jProbe]*uGap ;
     887    } else {
     888      deltaMul = colLower[jProbe]-1.0 ;
     889      if (aip >= 0) {
     890        delta = lGap ;
     891        revisebi = false ;
     892      } else {
     893        delta = uGap ;
    897894      }
    898       assert(sum == sum2) ;
    899 /*
    900   Check effectiveness. Add the cut only if it's sufficiently effective. (If
    901   we're strengthening existing constraints, needEffectiveness is quite low.)
    902 
    903   TODO: (*) I can't justify colLower in uGap*(l<p>+1.0). When I work
    904         the math, b'<i> = b<i> - (b<i> - U'<i>) = b<i> - uGap. I'll keep
    905         trying, on the theory that it's some attempt at general integers, but
    906         I'm thinking it's wrong. Note that for binary variables, l<p> = 0 and
    907         there's no problem.   -- lh, 110113 --
    908 
    909   TODO: I don't understand what's going on with the first two calculations
    910         for effectiveness. First off, sum2 and sum-uGap*colsol[j] should be
    911         exactly the same value (see notes with previous calculations). Then
    912         there's the question `Why divide by (b<i>-U<i>)?' in the second
    913         calculation. This inflates the effectiveness for a tiny uGap. A
    914         normalisation, perhaps?  -- lh, 110107 --
    915 
    916   TODO: And why go through the effort of setting the row bounds and
    917         effectiveness in the OsiRowCut, before we've decided that the cut will
    918         be used?  -- lh, 110107 --
    919 */
    920       OsiRowCut rc ;
    921       rc.setLb(-DBL_MAX) ;
    922       // (*) double ub = rowUpper[irow]-uGap*(colLower[jProbe]+1.0) ;
    923       double ub = rowUpper[irow]-uGap ;
    924       rc.setUb(ub) ;
    925       double effectiveness = sum2-ub ;
    926       effectiveness =
    927           CoinMax(effectiveness,
    928                   (sum-uGap*colsol[jProbe]-maxR[irow])/uGap) ;
    929       if (!saw_aip)
    930         effectiveness = CoinMax(1.0e-7,effectiveness) ;
    931       rc.setEffectiveness(effectiveness) ;
    932       // rc.setEffectiveness((sum-uGap*colsol[jProbe]-maxR[irow])/uGap) ;
    933       if (rc.effectiveness() > needEffectiveness) {
    934         rc.setRow(n,index,element,false) ;
    935 #       if CGL_DEBUG > 0
    936         if (debugger) assert(!debugger->invalidCut(rc));
    937 #       endif
    938 #       ifdef STRENGTHEN_PRINT
    939         if (canReplace && rowLower[irow] < -1.0e20) {
    940           printf("Strengthen Cut (1):\n") ;
    941           dump_row(irow,rc.lb(),rc.ub(),
    942                    nan(""),nan(""),&si,true,false,4,
    943                    n,index,element,
    944                    1.0e-10,colLower,colUpper) ;
    945           printf("Original Row:\n") ;
    946           int k = rowStart[irow] ;
    947           dump_row(irow,rowLower[irow],rowUpper[irow],
    948                    minR[irow],maxR[irow],&si,true,false,4,
    949                    rowStart[irow+1]-k,&column[k],&rowElements[k],
    950                    1.0e-10,colLower,colUpper) ;
    951         }
    952 #       endif
     895    }
     896    if (CoinAbs(delta) < primalTolerance_ || CoinAbs(delta) > bigCoeff)
     897      continue ;
     898/*
     899  Now decide if we have something that cuts off the current solution. Augment
     900  the lhs activity with the contribution for a'<ip>x*<p>, calculate the new
     901  rhs value, and compare.
     902  As an alternate measure of effectiveness, consider the gap between the
     903  current activity and the revised lhs bound, normalised by the gap between
     904  the original rhs and the revised lhs bound.
     905
     906  We'll also generate the cut if we can strengthen it in place and we're not
     907  dealing with a range constraint. (The reason for excluding range constraints
     908  is that we might try to alter a<ip> against both b<i> and blow<i>. That way
     909  lies madness.)
     910
     911  TODO: It's not clear to me how the first two effectiveness calculations
     912        relate to one another. Think more on this -- lh, 110115 --
     913*/
     914    double aipPrime = aip+delta ;
     915    bool aipPrimeNonZero = true ;
     916    if (CoinAbs(aipPrime) < tinyCoeff) {
     917      aipPrime = 0.0 ;
     918      aipPrimeNonZero = false ;
     919    }
     920    double xp = colsol[jProbe] ;
     921    sum += aipPrime*xp ;
     922    double biPrime = DBL_MAX ;
     923    double blowiPrime = -DBL_MAX ;
     924    double effectiveness = 0.0 ;
     925    bool genCut = false ;
     926    if (revisebi) {
     927      biPrime = rowUpper[irow]+deltaMul*delta ;
     928      effectiveness = sum-biPrime ;
     929      effectiveness = CoinMax(effectiveness,(sum-maxR[irow])/uGap) ;
     930    } else {
     931      blowiPrime = rowLower[irow]+deltaMul*delta ;
     932      effectiveness = blowiPrime-sum ;
     933      effectiveness = CoinMax(effectiveness,(minR[irow]-sum)/lGap) ;
     934    }
     935    if (!aipNonZero && aipPrimeNonZero)
     936      effectiveness = CoinMax(effectiveness,aipZeroEffectiveness) ;
     937    if (effectiveness > needEffectiveness) genCut = true ;
     938    if (info->strengthenRow && !isRangeCon) genCut = true ;
     939/*
     940  Are we going to generate the cut? If not, on to the next iteration.
     941*/
     942    if (!genCut) continue ;
     943/*
     944  Generate the coefficients. Copy whatever's present and plug in aipPrime at
     945  the end.
     946*/
     947    int n = 0 ;
     948    int aip_n = -1 ;
     949    for (CoinBigIndex kk = rowStart[irow] ; kk < rowStart[irow+1] ; kk++) {
     950      int k = column[kk] ;
     951      double aik = rowElements[kk] ;
     952      if (k == jProbe)
     953        aip_n = k ;
     954      index[n] = k ;
     955      element[n++] = aik ;
     956    }
     957    if (aip_n < 0) {
     958      aip_n = n ;
     959      n++ ;
     960    }
     961    index[aip_n] = jProbe ;
     962    element[aip_n] = aipPrime ;
     963/*
     964  Fill in a cut structure with the cut.
     965*/
     966    OsiRowCut rc ;
     967    rc.setLb(blowiPrime) ;
     968    rc.setUb(biPrime) ;
     969    rc.setEffectiveness(effectiveness) ;
     970    rc.setRow(n,index,element,false) ;
     971#   if CGL_DEBUG > 0
     972    if (debugger) assert(!debugger->invalidCut(rc));
     973#   endif
     974#   ifdef STRENGTHEN_PRINT
     975    if (canReplace && !isRangeCon) {
     976      printf("Strengthen Cut (1):\n") ;
     977      dump_row(irow,rc.lb(),rc.ub(),
     978               nan(""),nan(""),&si,true,false,4,
     979               n,index,element,
     980               1.0e-10,colLower,colUpper) ;
     981      printf("Original Row:\n") ;
     982      int k = rowStart[irow] ;
     983      dump_row(irow,rowLower[irow],rowUpper[irow],
     984               minR[irow],maxR[irow],&si,true,false,4,
     985               rowStart[irow+1]-k,&column[k],&rowElements[k],
     986               1.0e-10,colLower,colUpper) ;
     987    }
     988#   endif
    953989/*
    954990  If we're in preprocessing, we might try to simply replace the existing
     
    959995  we modified the constraint system during preprocessing in gutsOfGenerateCuts.
    960996
    961   TODO: Seems a bit disingenuous to fail at replacement now, given that
    962         effectiveness is artificially low. Notice again the inconsistent use
    963         of finite infinities on the row lb.  -- lh, 101128 --
    964 
    965   TODO: To elaborate on the above, it seems to me that we can get here with
     997  Effectiveness, if we're strengthening in place, seems to be absolute size of
     998  coefficients; smaller is better. (Why?)
     999
     1000  TODO: It seems to me that we can get here with
    9661001        justReplace = true and canReplace = false, and this condition is
    9671002        constant over an iteration of the way loop. In other words, we've done
    9681003        all the work to generate this cut and we knew before we started that
    9691004        we would discard it here.  -- lh, 110107 --
    970 */
    971         int realRow = (canReplace && rowLower[irow] < -1.0e20)?(irow):(-1) ;
    972         if (realRows && realRow >= 0)
    973           realRow = realRows[realRow] ;
    974         if (!justReplace) {
    975           rowCut.addCutIfNotDuplicate(rc,realRow) ;
    976         } else if (realRow >= 0) {
    977           double effectiveness = 0.0 ;
    978           for (int i = 0 ; i < n ; i++)
    979             effectiveness += fabs(element[i]) ;
    980           if (!info->strengthenRow[realRow] ||
    981               info->strengthenRow[realRow]->effectiveness() > effectiveness) {
    982             delete info->strengthenRow[realRow] ;
    983             rc.setEffectiveness(effectiveness) ;
    984             info->strengthenRow[realRow]=rc.clone() ;
    985           }
     1005        Put in an assert to see if we ever do all the work, only to reject
     1006        the cut.  -- lh, 110115 --
     1007*/
     1008      int realRow = (canReplace && !isRangeCon)?(irow):(-1) ;
     1009      if (realRows && realRow >= 0)
     1010        realRow = realRows[realRow] ;
     1011      if (!justReplace) {
     1012        rowCut.addCutIfNotDuplicate(rc,realRow) ;
     1013      } else if (realRow >= 0) {
     1014        double effectiveness = 0.0 ;
     1015        for (int i = 0 ; i < n ; i++)
     1016          effectiveness += CoinAbs(element[i]) ;
     1017        if (!info->strengthenRow[realRow] ||
     1018            info->strengthenRow[realRow]->effectiveness() > effectiveness) {
     1019          delete info->strengthenRow[realRow] ;
     1020          rc.setEffectiveness(effectiveness) ;
     1021          info->strengthenRow[realRow] = rc.clone() ;
     1022        } else {
     1023#       if CGL_DEBUG > 0
     1024          std::cout
     1025            << "INPLACE: rejected on cut coeff magnitude." << std::endl ;
     1026#       endif
    9861027        }
     1028      } else {
     1029#       if CGL_DEBUG > 0
     1030          std::cout
     1031            << "INPLACE: rejected because no real row." << std::endl ;
     1032#       endif
    9871033      }
    9881034    }
    989 /*
    990   And repeat working against the lower bound L(i). As in so many other places
    991   in this code, it's the identical functionality, with some subtle edits that
    992   distinguish the L(i) math from the U(i) math.
    993 */
    994     if (lGap > primalTolerance_ &&
    995         (sum+lGap*colsol[jProbe] < minR[irow]-primalTolerance_ ||
    996          (info->strengthenRow && rowUpper[irow] > -1.0e20))) {
    997       int n = 0 ;
    998       bool saw_aip = false ;
    999       double sum2 = 0.0 ;
    1000       for (int kk = rowStart[irow] ; kk < rowStart[irow+1] ; kk++) {
    1001         int kColumn = column[kk] ;
    1002         double el = rowElements[kk] ;
    1003         if (kColumn != jProbe) {
    1004           index[n] = kColumn ;
    1005           element[n++] = el ;
    1006         } else {
    1007           el = el+lGap ;
    1008           if (fabs(el) > 1.0e-12) {
    1009             index[n] = kColumn ;
    1010             element[n++] = el ;
    1011           }
    1012           saw_aip = true ;
    1013         }
    1014         sum2 += colsol[kColumn]*el ;
    1015       }
    1016       if (!saw_aip) {
    1017         index[n] = jProbe ;
    1018         element[n++] = lGap ;
    1019         sum2 += colsol[jProbe]*lGap ;
    1020       }
    1021       OsiRowCut rc ;
    1022       double lb = rowLower[irow]+lGap*(colLower[jProbe]+1.0) ;
    1023       rc.setLb(lb) ;
    1024       rc.setUb(DBL_MAX) ;
    1025       // effectiveness
    1026       double effectiveness = lb-sum2 ;
    1027       effectiveness = CoinMax(effectiveness,
    1028                               (minR[irow]-sum-lGap*colsol[jProbe])/lGap) ;
    1029       if (!saw_aip)
    1030         effectiveness = CoinMax(1.0e-7,effectiveness) ;
    1031       rc.setEffectiveness(effectiveness) ;
    1032       if (rc.effectiveness() > needEffectiveness) {
    1033         rc.setRow(n,index,element,false) ;
    1034 #       if CGL_DEBUG > 0
    1035         if (debugger) assert(!debugger->invalidCut(rc));
    1036 #       endif
    1037 #       ifdef STRENGTHEN_PRINT
    1038         if (canReplace && rowUpper[irow] > 1.0e20) {
    1039           printf("Strengthen Cut (2):\n") ;
    1040           dump_row(irow,rc.lb(),rc.ub(),
    1041                    nan(""),nan(""),&si,true,false,4,
    1042                    n,index,element,
    1043                    1.0e-10,colLower,colUpper) ;
    1044           printf("Original Row:\n") ;
    1045           int k = rowStart[irow] ;
    1046           dump_row(irow,rowLower[irow],rowUpper[irow],
    1047                    minR[irow],maxR[irow],&si,true,false,4,
    1048                    rowStart[irow+1]-k,&column[k],&rowElements[k],
    1049                    1.0e-10,colLower,colUpper) ;
    1050         }
    1051 #       endif
    1052 
    1053         int realRow = (canReplace&&rowUpper[irow]>1.0e20) ? irow : -1 ;
    1054         if (realRows && realRow >= 0)
    1055           realRow = realRows[realRow] ;
    1056         if (!justReplace) {
    1057           rowCut.addCutIfNotDuplicate(rc,realRow) ;
    1058         } else if (realRow >= 0) {
    1059           double effectiveness = 0.0 ;
    1060           for (int i = 0 ; i < n ; i++)
    1061             effectiveness += fabs(element[i]) ;
    1062           if (!info->strengthenRow[realRow] ||
    1063               info->strengthenRow[realRow]->effectiveness() > effectiveness) {
    1064             delete info->strengthenRow[realRow] ;
    1065             rc.setEffectiveness(effectiveness) ;
    1066             info->strengthenRow[realRow] = rc.clone() ;
    1067           }
    1068         }
    1069       }
    1070     }
    1071   }
    10721035
    10731036# if CGL_DEBUG > 0
     
    10761039    << rowCut.numberCuts() << " cuts." << std::endl ;
    10771040# endif
     1041
    10781042  return ;
    10791043}
     
    13581322  }
    13591323  cutoff *= direction ;
    1360   if (fabs(cutoff) > 1.0e30)
     1324  if (CoinAbs(cutoff) > 1.0e30)
    13611325    assert (cutoff > 1.0e30) ;
    13621326  double current = si.getObjValue() ;
     
    17011665      const double lj = colLower[j] ;
    17021666      const double uj = colUpper[j] ;
    1703       const bool downIsLower = (fabs(down-colLower[j]) < 1.0e-7) ;
    1704       const bool upIsUpper = (fabs(up-colUpper[j]) < 1.0e-7) ;
     1667      const bool downIsLower = (CoinAbs(down-colLower[j]) < 1.0e-7) ;
     1668      const bool upIsUpper = (CoinAbs(up-colUpper[j]) < 1.0e-7) ;
    17051669#     endif
    17061670/*
     
    17611725        assert(lj == colLower[j]) ;
    17621726        assert(uj == colUpper[j]) ;
    1763         assert(downIsLower == (fabs(down-colLower[j]) < 1.0e-7)) ;
    1764         assert(upIsUpper == (fabs(up-colUpper[j]) < 1.0e-7)) ;
     1727        assert(downIsLower == (CoinAbs(down-colLower[j]) < 1.0e-7)) ;
     1728        assert(upIsUpper == (CoinAbs(up-colUpper[j]) < 1.0e-7)) ;
    17651729#       endif
    17661730
     
    17691733          solMovement = down-colsol[j] ;
    17701734          assert(movement < -0.99999) ;
    1771           if (fabs(down-colLower[j]) < 1.0e-7) {
     1735          if (CoinAbs(down-colLower[j]) < 1.0e-7) {
    17721736            goingToTrueBound = 2 ;
    17731737            down = colLower[j] ;
     
    17771741          solMovement = up-colsol[j] ;
    17781742          assert(movement > 0.99999) ;
    1779           if (fabs(up-colUpper[j]) < 1.0e-7) {
     1743          if (CoinAbs(up-colUpper[j]) < 1.0e-7) {
    17801744            goingToTrueBound = 2 ;
    17811745            up = colUpper[j] ;
     
    18231787        // Alert for general integer with nontrivial range.
    18241788        // Also last use of solval
    1825         if (fabs(movement)>1.01) {
     1789        if (CoinAbs(movement)>1.01) {
    18261790          printf("big %d %g %g %g\n",j,colLower[j],solval,colUpper[j]) ;
    18271791        }
     
    18681832  Is this variable now fixed?
    18691833*/
    1870         if (fabs(colUpper[j]-colLower[j]) < 1.0e-6)
     1834        if (CoinAbs(colUpper[j]-colLower[j]) < 1.0e-6)
    18711835          markC[j] = tightenUpper|tightenLower ;
    18721836/*
     
    23492313        see how it looks.  -- lh, 101203 --
    23502314*/
    2351                       if (fabs(colUpper[kcol]-colLower[kcol]) < 1.0e-6) {
     2315                      if (CoinAbs(colUpper[kcol]-colLower[kcol]) < 1.0e-6) {
    23522316                        markC[kcol] = (tightenLower|tightenUpper) ;
    23532317                      }
     
    23922356                      colUpper[kcol]=newUpper ;
    23932357                      columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_ ;
    2394                       if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
     2358                      if (CoinAbs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
    23952359                        markC[kcol] = (tightenLower|tightenUpper); // say fixed
    23962360                      }
     
    24862450                      colLower[kcol]=newLower ;
    24872451                      columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_ ;
    2488                       if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
     2452                      if (CoinAbs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
    24892453                        markC[kcol]= (tightenLower|tightenUpper); // say fixed
    24902454                      }
     
    25722536                      colUpper[kcol]=newUpper ;
    25732537                      columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_ ;
    2574                       if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
     2538                      if (CoinAbs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
    25752539                        markC[kcol]= (tightenLower|tightenUpper); // say fixed
    25762540                      }
     
    26892653                      colLower[kcol]=newLower ;
    26902654                      columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_ ;
    2691                       if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
     2655                      if (CoinAbs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
    26922656                        markC[kcol]= (tightenLower|tightenUpper); // say fixed
    26932657                      }
     
    27272691                      colUpper[kcol]=newUpper ;
    27282692                      columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_ ;
    2729                       if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
     2693                      if (CoinAbs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
    27302694                        markC[kcol]= (tightenLower|tightenUpper); // say fixed
    27312695                      }
     
    28102774                      colUpper[kcol]=newUpper ;
    28112775                      columnGap[kcol] = newUpper-colLower[kcol]-primalTolerance_ ;
    2812                       if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
     2776                      if (CoinAbs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
    28132777                        markC[kcol]= (tightenLower|tightenUpper); // say fixed
    28142778                      }
     
    28932857                      colLower[kcol]=newLower ;
    28942858                      columnGap[kcol] = colUpper[kcol]-newLower-primalTolerance_ ;
    2895                       if (fabs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
     2859                      if (CoinAbs(colUpper[kcol]-colLower[kcol])<1.0e-6) {
    28962860                        markC[kcol]= (tightenLower|tightenUpper); // say fixed
    28972861                      }
     
    31243088*/
    31253089          if ((rowCuts&0x02) != 0 && goingToTrueBound && !anyColumnCuts)
    3126             strengthenCoeff(j,primalTolerance_,justReplace,canReplace,
     3090            strengthenCoeff(j,iway,primalTolerance_,justReplace,canReplace,
    31273091                            needEffectiveness,si,rowCut,
    31283092                            rowCopy,colUpper,colLower,colsol,nstackR,stackR,
     
    31913155                         index,element) ;
    31923156            if ((rowCuts&0x02) != 0 && goingToTrueBound && !anyColumnCuts)
    3193               strengthenCoeff(j,primalTolerance_,justReplace,canReplace,
     3157              strengthenCoeff(j,iway,primalTolerance_,justReplace,canReplace,
    31943158                              needEffectiveness,si,rowCut,
    31953159                              rowCopy,colUpper,colLower,colsol,nstackR,stackR,
     
    32923256        -- lh, 101128 --
    32933257*/
    3294                     if (fabs(element[0]) > 1.0e-8) {
     3258                    if (CoinAbs(element[0]) > 1.0e-8) {
    32953259                      element[1] = 1.0 ;
    32963260                      rc.setRow(2,index,element,false) ;
Note: See TracChangeset for help on using the changeset viewer.