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 "CbcCountRowCut.hpp" |
---|
11 | #include "CbcNode.hpp" |
---|
12 | // Default Constructor |
---|
13 | CbcCountRowCut::CbcCountRowCut () |
---|
14 | : |
---|
15 | OsiRowCut(), |
---|
16 | owner_(NULL), |
---|
17 | ownerCut_(-1), |
---|
18 | numberPointingToThis_(0), |
---|
19 | whichCutGenerator_(-1) |
---|
20 | { |
---|
21 | #ifdef CHECK_CUT_COUNTS |
---|
22 | printf("CbcCountRowCut default constructor %x\n",this); |
---|
23 | #endif |
---|
24 | } |
---|
25 | |
---|
26 | // Copy Constructor |
---|
27 | CbcCountRowCut::CbcCountRowCut (const OsiRowCut & rhs) |
---|
28 | : OsiRowCut(rhs), |
---|
29 | owner_(NULL), |
---|
30 | ownerCut_(-1), |
---|
31 | numberPointingToThis_(0), |
---|
32 | whichCutGenerator_(-1) |
---|
33 | { |
---|
34 | #ifdef CHECK_CUT_COUNTS |
---|
35 | printf("CbcCountRowCut constructor %x from RowCut\n",this); |
---|
36 | #endif |
---|
37 | } |
---|
38 | // Copy Constructor |
---|
39 | CbcCountRowCut::CbcCountRowCut (const OsiRowCut & rhs, |
---|
40 | CbcNodeInfo * info, int whichOne, |
---|
41 | int whichGenerator) |
---|
42 | : OsiRowCut(rhs), |
---|
43 | owner_(info), |
---|
44 | ownerCut_(whichOne), |
---|
45 | numberPointingToThis_(0), |
---|
46 | whichCutGenerator_(whichGenerator) |
---|
47 | { |
---|
48 | #ifdef CHECK_CUT_COUNTS |
---|
49 | printf("CbcCountRowCut constructor %x from RowCut and info\n",this); |
---|
50 | #endif |
---|
51 | } |
---|
52 | CbcCountRowCut::~CbcCountRowCut() |
---|
53 | { |
---|
54 | #ifdef CHECK_CUT_COUNTS |
---|
55 | printf("CbcCountRowCut destructor %x - references %d\n",this, |
---|
56 | numberPointingToThis_); |
---|
57 | #endif |
---|
58 | // Look at owner and delete |
---|
59 | owner_->deleteCut(ownerCut_); |
---|
60 | ownerCut_=-1234567; |
---|
61 | } |
---|
62 | // Increment number of references |
---|
63 | void |
---|
64 | CbcCountRowCut::increment(int change) |
---|
65 | { |
---|
66 | assert(ownerCut_!=-1234567); |
---|
67 | numberPointingToThis_+=change; |
---|
68 | } |
---|
69 | |
---|
70 | // Decrement number of references and return number left |
---|
71 | int |
---|
72 | CbcCountRowCut::decrement(int change) |
---|
73 | { |
---|
74 | assert(ownerCut_!=-1234567); |
---|
75 | //assert(numberPointingToThis_>=change); |
---|
76 | assert(numberPointingToThis_>=0); |
---|
77 | if(numberPointingToThis_<change) { |
---|
78 | assert(numberPointingToThis_>0); |
---|
79 | printf("negative cut count %d - %d\n",numberPointingToThis_, change); |
---|
80 | change = numberPointingToThis_; |
---|
81 | } |
---|
82 | numberPointingToThis_-=change; |
---|
83 | return numberPointingToThis_; |
---|
84 | } |
---|
85 | |
---|
86 | // Set information |
---|
87 | void |
---|
88 | CbcCountRowCut::setInfo(CbcNodeInfo * info, int whichOne) |
---|
89 | { |
---|
90 | owner_=info; |
---|
91 | ownerCut_=whichOne; |
---|
92 | } |
---|
93 | |
---|