source: trunk/Cbc/src/CbcCountRowCut.cpp @ 1121

Last change on this file since 1121 was 1121, checked in by forrest, 10 years ago

compiler warnings, deterministic parallel and stability

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#if defined(_MSC_VER)
4// Turn off compiler warning about long names
5#  pragma warning(disable:4786)
6#endif
7#include <cassert>
8
9#include "OsiRowCut.hpp"
10#include "CbcModel.hpp"
11#include "CbcCountRowCut.hpp"
12#include "CbcNode.hpp"
13//#define CHECK_CUT_COUNTS
14// Default Constructor
15CbcCountRowCut::CbcCountRowCut ()
16  :
17  OsiRowCut(),
18  owner_(NULL),
19  ownerCut_(-1),
20  numberPointingToThis_(0),
21  whichCutGenerator_(-1)
22{
23#ifdef CHECK_CUT_COUNTS
24  printf("CbcCountRowCut default constructor %x\n",this);
25#endif
26}
27   
28// Copy Constructor
29CbcCountRowCut::CbcCountRowCut (const OsiRowCut & rhs)
30  : OsiRowCut(rhs),
31    owner_(NULL),
32    ownerCut_(-1),
33    numberPointingToThis_(0),
34    whichCutGenerator_(-1)
35{
36#ifdef CHECK_CUT_COUNTS
37  printf("CbcCountRowCut constructor %x from RowCut\n",this);
38#endif
39}
40// Copy Constructor
41CbcCountRowCut::CbcCountRowCut (const OsiRowCut & rhs,
42                                CbcNodeInfo * info, int whichOne,
43                                int whichGenerator,
44                                int numberPointingToThis)
45  : OsiRowCut(rhs),
46    owner_(info),
47    ownerCut_(whichOne),
48    numberPointingToThis_(numberPointingToThis),
49    whichCutGenerator_(whichGenerator)
50{
51#ifdef CHECK_CUT_COUNTS
52  printf("CbcCountRowCut constructor %x from RowCut and info %d\n",
53         this,numberPointingToThis_);
54#endif
55  assert (!numberPointingToThis||numberPointingToThis==1000000000);
56}
57CbcCountRowCut::~CbcCountRowCut()
58{
59#ifdef CHECK_CUT_COUNTS
60  printf("CbcCountRowCut destructor %x - references %d\n",this,
61         numberPointingToThis_);
62#endif
63  // Look at owner and delete
64  owner_->deleteCut(ownerCut_);
65  ownerCut_=-1234567;
66}
67// Increment number of references
68void 
69CbcCountRowCut::increment(int change)
70{
71  assert(ownerCut_!=-1234567);
72  numberPointingToThis_+=change;
73}
74
75// Decrement number of references and return number left
76int 
77CbcCountRowCut::decrement(int change)
78{
79  assert(ownerCut_!=-1234567);
80  // See if plausible number
81  if (change<900000000) {
82    //assert(numberPointingToThis_>=change);
83    assert(numberPointingToThis_>=0);
84    if(numberPointingToThis_<change) {
85      assert(numberPointingToThis_>0);
86      printf("negative cut count %d - %d\n",numberPointingToThis_, change);
87      change = numberPointingToThis_;
88    }
89    numberPointingToThis_-=change;
90  }
91  return numberPointingToThis_;
92}
93
94// Set information
95void 
96CbcCountRowCut::setInfo(CbcNodeInfo * info, int whichOne)
97{
98  owner_=info;
99  ownerCut_=whichOne;
100}
101// Returns true if can drop cut if slack basic
102bool 
103CbcCountRowCut::canDropCut(const OsiSolverInterface * solver, int iRow) const
104{
105  // keep if COIN_DBL_MAX otherwise keep if slack zero
106  if (effectiveness()<1.0e20) {
107    return true;
108  } else if (effectiveness()!=COIN_DBL_MAX) {
109    if (iRow>=solver->getNumRows())
110      return true;
111    const double * rowActivity = solver->getRowActivity();
112    const double * rowLower = solver->getRowLower();
113    const double * rowUpper = solver->getRowUpper();
114    double tolerance;
115    solver->getDblParam(OsiPrimalTolerance,tolerance) ;
116    double value = rowActivity[iRow];
117    if (value<rowLower[iRow]+tolerance||
118        value>rowUpper[iRow]-tolerance)
119      return false;
120    else
121      return true;
122  } else {
123    return false;
124  }
125}
126
Note: See TracBrowser for help on using the repository browser.