Ignore:
Timestamp:
Nov 9, 2009 6:33:07 PM (10 years ago)
Author:
EdwinStraver
Message:

Changed formatting using AStyle -A4 -p

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/Cbc/src/CbcCountRowCut.cpp

    r1271 r1286  
    1313#include "CbcNode.hpp"
    1414//#define CHECK_CUT_COUNTS
    15 // Default Constructor 
     15// Default Constructor
    1616CbcCountRowCut::CbcCountRowCut ()
    17   :
    18   OsiRowCut(),
    19   owner_(NULL),
    20   ownerCut_(-1),
    21   numberPointingToThis_(0),
    22   whichCutGenerator_(-1)
     17        :
     18        OsiRowCut(),
     19        owner_(NULL),
     20        ownerCut_(-1),
     21        numberPointingToThis_(0),
     22        whichCutGenerator_(-1)
    2323{
    2424#ifdef CHECK_CUT_COUNTS
    25   printf("CbcCountRowCut default constructor %x\n",this);
     25    printf("CbcCountRowCut default constructor %x\n", this);
    2626#endif
    2727}
    28    
    29 // Copy Constructor 
     28
     29// Copy Constructor
    3030CbcCountRowCut::CbcCountRowCut (const OsiRowCut & rhs)
    31   : OsiRowCut(rhs),
    32     owner_(NULL),
    33     ownerCut_(-1),
    34     numberPointingToThis_(0),
    35     whichCutGenerator_(-1)
     31        : OsiRowCut(rhs),
     32        owner_(NULL),
     33        ownerCut_(-1),
     34        numberPointingToThis_(0),
     35        whichCutGenerator_(-1)
    3636{
    3737#ifdef CHECK_CUT_COUNTS
    38   printf("CbcCountRowCut constructor %x from RowCut\n",this);
     38    printf("CbcCountRowCut constructor %x from RowCut\n", this);
    3939#endif
    4040}
    41 // Copy Constructor 
     41// Copy Constructor
    4242CbcCountRowCut::CbcCountRowCut (const OsiRowCut & rhs,
    43                                 CbcNodeInfo * info, int whichOne,
    44                                 int whichGenerator,
    45                                 int numberPointingToThis)
    46   : OsiRowCut(rhs),
    47     owner_(info),
    48     ownerCut_(whichOne),
    49     numberPointingToThis_(numberPointingToThis),
    50     whichCutGenerator_(whichGenerator)
     43                                CbcNodeInfo * info, int whichOne,
     44                                int whichGenerator,
     45                                int numberPointingToThis)
     46        : OsiRowCut(rhs),
     47        owner_(info),
     48        ownerCut_(whichOne),
     49        numberPointingToThis_(numberPointingToThis),
     50        whichCutGenerator_(whichGenerator)
    5151{
    5252#ifdef CHECK_CUT_COUNTS
    53   printf("CbcCountRowCut constructor %x from RowCut and info %d\n",
    54          this,numberPointingToThis_);
     53    printf("CbcCountRowCut constructor %x from RowCut and info %d\n",
     54           this, numberPointingToThis_);
    5555#endif
    56   assert (!numberPointingToThis||numberPointingToThis==1000000000);
     56    assert (!numberPointingToThis || numberPointingToThis == 1000000000);
    5757}
    5858CbcCountRowCut::~CbcCountRowCut()
    5959{
    6060#ifdef CHECK_CUT_COUNTS
    61   printf("CbcCountRowCut destructor %x - references %d\n",this,
    62         numberPointingToThis_);
     61    printf("CbcCountRowCut destructor %x - references %d\n", this,
     62          numberPointingToThis_);
    6363#endif
    64   // Look at owner and delete
    65   owner_->deleteCut(ownerCut_);
    66   ownerCut_=-1234567;
     64    // Look at owner and delete
     65    owner_->deleteCut(ownerCut_);
     66    ownerCut_ = -1234567;
    6767}
    6868// Increment number of references
    69 void 
     69void
    7070CbcCountRowCut::increment(int change)
    7171{
    72   assert(ownerCut_!=-1234567);
    73   numberPointingToThis_+=change;
     72    assert(ownerCut_ != -1234567);
     73    numberPointingToThis_ += change;
    7474}
    7575
    7676// Decrement number of references and return number left
    77 int 
     77int
    7878CbcCountRowCut::decrement(int change)
    7979{
    80   assert(ownerCut_!=-1234567);
    81   // See if plausible number
    82   if (change<900000000) {
    83     //assert(numberPointingToThis_>=change);
    84     assert(numberPointingToThis_>=0);
    85     if(numberPointingToThis_<change) {
    86       assert(numberPointingToThis_>0);
    87       printf("negative cut count %d - %d\n",numberPointingToThis_, change);
    88       change = numberPointingToThis_;
     80    assert(ownerCut_ != -1234567);
     81    // See if plausible number
     82    if (change < 900000000) {
     83        //assert(numberPointingToThis_>=change);
     84        assert(numberPointingToThis_ >= 0);
     85        if (numberPointingToThis_ < change) {
     86            assert(numberPointingToThis_ > 0);
     87            printf("negative cut count %d - %d\n", numberPointingToThis_, change);
     88            change = numberPointingToThis_;
     89        }
     90        numberPointingToThis_ -= change;
    8991    }
    90     numberPointingToThis_-=change;
    91   }
    92   return numberPointingToThis_;
     92    return numberPointingToThis_;
    9393}
    9494
    9595// Set information
    96 void 
     96void
    9797CbcCountRowCut::setInfo(CbcNodeInfo * info, int whichOne)
    9898{
    99   owner_=info;
    100   ownerCut_=whichOne;
     99    owner_ = info;
     100    ownerCut_ = whichOne;
    101101}
    102102// Returns true if can drop cut if slack basic
    103 bool 
     103bool
    104104CbcCountRowCut::canDropCut(const OsiSolverInterface * solver, int iRow) const
    105105{
    106   // keep if COIN_DBL_MAX otherwise keep if slack zero
    107   if (effectiveness()<1.0e20) {
    108     return true;
    109   } else if (effectiveness()!=COIN_DBL_MAX) {
    110     if (iRow>=solver->getNumRows())
    111       return true;
    112     const double * rowActivity = solver->getRowActivity();
    113     const double * rowLower = solver->getRowLower();
    114     const double * rowUpper = solver->getRowUpper();
    115     double tolerance;
    116     solver->getDblParam(OsiPrimalTolerance,tolerance) ;
    117     double value = rowActivity[iRow];
    118     if (value<rowLower[iRow]+tolerance||
    119         value>rowUpper[iRow]-tolerance)
    120       return false;
    121     else
    122       return true;
    123   } else {
    124     return false;
    125   }
     106    // keep if COIN_DBL_MAX otherwise keep if slack zero
     107    if (effectiveness() < 1.0e20) {
     108        return true;
     109    } else if (effectiveness() != COIN_DBL_MAX) {
     110        if (iRow >= solver->getNumRows())
     111            return true;
     112        const double * rowActivity = solver->getRowActivity();
     113        const double * rowLower = solver->getRowLower();
     114        const double * rowUpper = solver->getRowUpper();
     115        double tolerance;
     116        solver->getDblParam(OsiPrimalTolerance, tolerance) ;
     117        double value = rowActivity[iRow];
     118        if (value < rowLower[iRow] + tolerance ||
     119                value > rowUpper[iRow] - tolerance)
     120            return false;
     121        else
     122            return true;
     123    } else {
     124        return false;
     125    }
    126126}
    127127
Note: See TracChangeset for help on using the changeset viewer.