Changeset 474 for trunk


Ignore:
Timestamp:
Nov 3, 2006 10:38:33 AM (13 years ago)
Author:
forrest
Message:

fix for gcd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcModel.cpp

    r434 r474  
    326326  2520.0 is used as it is a nice multiple of 2,3,5,7
    327327*/
    328     if (possibleMultiple&&maximumCost)
    329     { int increment = 0 ;
    330       double multiplier = 2520.0 ;
    331       while (10.0*multiplier*maximumCost < 1.0e8)
    332         multiplier *= 10.0 ;
    333 
    334       for (iColumn = 0 ; iColumn < numberColumns ; iColumn++)
    335       { if (upper[iColumn] > lower[iColumn]+1.0e-8)
    336         { if (isInteger(iColumn)&&objective[iColumn])
    337           { double value = fabs(objective[iColumn])*multiplier ;
     328  if (possibleMultiple&&maximumCost) {
     329    int increment = 0 ;
     330    double multiplier = 2520.0 ;
     331    while (10.0*multiplier*maximumCost < 1.0e8)
     332      multiplier *= 10.0 ;
     333    int bigIntegers = 0; // Count of large costs which are integer
     334    for (iColumn = 0 ; iColumn < numberColumns ; iColumn++) {
     335      if (upper[iColumn] > lower[iColumn]+1.0e-8) {
     336        if (isInteger(iColumn)&&objective[iColumn]) {
     337          double value = fabs(objective[iColumn])*multiplier ;
     338          if (value <2.1e9) {
    338339            int nearest = (int) floor(value+0.5) ;
    339340            if (fabs(value-floor(value+0.5)) > 1.0e-8)
    340             { increment = 0 ;
     341              { increment = 0 ;
    341342              break ; }
    342343            else if (!increment)
    343             { increment = nearest ; }
     344              { increment = nearest ; }
    344345            else
    345             { increment = gcd(increment,nearest) ; } } } }
     346              { increment = gcd(increment,nearest) ; }
     347          } else {
     348            // large value - may still be multiple of 1.0
     349            value = fabs(objective[iColumn]);
     350            if (fabs(value-floor(value+0.5)) > 1.0e-8) {
     351              increment=0;
     352              break;
     353            } else {
     354              bigIntegers++;
     355            }
     356          }
     357        }
     358      }
     359    }
    346360/*
    347361  If the increment beats the current value for objective change, install it.
     
    350364      { double value = increment ;
    351365        double cutoff = getDblParam(CbcModel::CbcCutoffIncrement) ;
     366        if (bigIntegers) {
     367          // allow for 1.0
     368          increment = gcd(increment,(int) multiplier);
     369          value = increment;
     370        }
    352371        value /= multiplier ;
    353372        if (value*0.999 > cutoff)
Note: See TracChangeset for help on using the changeset viewer.