Cbc
trunk
|
00001 /* $Id$ */ 00002 // Copyright (C) 2002, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef CbcCountRowCut_H 00007 #define CbcCountRowCut_H 00008 00009 00010 class OsiCuts; 00011 class OsiRowCut; 00012 class CbcNodeInfo; 00013 00014 //############################################################################# 00035 class CbcCountRowCut : public OsiRowCut { 00036 00037 public: 00038 00041 00043 CbcCountRowCut (); 00044 00046 CbcCountRowCut ( const OsiRowCut &); 00047 00049 CbcCountRowCut(const OsiRowCut &, CbcNodeInfo *, int whichOne, 00050 int whichGenerator = -1, int numberPointingToThis = 0); 00051 00058 virtual ~CbcCountRowCut (); 00060 00062 void increment(int change = 1); 00063 00065 int decrement(int change = 1); 00066 00074 void setInfo(CbcNodeInfo *, int whichOne); 00075 00077 inline int numberPointingToThis() { 00078 return numberPointingToThis_; 00079 } 00080 00082 inline int whichCutGenerator() const { 00083 return whichCutGenerator_; 00084 } 00085 00087 bool canDropCut(const OsiSolverInterface * solver, int row) const; 00088 00089 #ifdef CHECK_CUT_COUNTS 00090 // Just for printing sanity checks 00091 int tempNumber_; 00092 #endif 00093 00094 private: 00095 00097 CbcCountRowCut(const CbcCountRowCut &); 00098 00100 CbcCountRowCut & operator=(const CbcCountRowCut& rhs); 00101 00103 CbcNodeInfo * owner_; 00104 00107 int ownerCut_; 00108 00110 int numberPointingToThis_; 00111 00118 int whichCutGenerator_; 00119 00120 }; 00130 // for hashing 00131 typedef struct { 00132 int index, next; 00133 } CoinHashLink; 00134 class CbcRowCuts { 00135 public: 00136 00137 CbcRowCuts(int initialMaxSize=0, int hashMultiplier=4 ); 00138 ~CbcRowCuts(); 00139 CbcRowCuts(const CbcRowCuts& rhs); 00140 CbcRowCuts& operator=(const CbcRowCuts& rhs); 00141 inline OsiRowCut2 * cut(int sequence) const 00142 { return rowCut_[sequence];} 00143 inline int numberCuts() const 00144 { return numberCuts_;} 00145 inline int sizeRowCuts() const 00146 { return numberCuts_;} 00147 inline OsiRowCut * rowCutPtr(int sequence) 00148 { return rowCut_[sequence];} 00149 void eraseRowCut(int sequence); 00150 // Return 0 if added, 1 if not, -1 if not added because of space 00151 int addCutIfNotDuplicate(const OsiRowCut & cut,int whichType=0); 00152 // Return 0 if added, 1 if not, -1 if not added because of space 00153 int addCutIfNotDuplicateWhenGreedy(const OsiRowCut & cut,int whichType=0); 00154 // Add in cuts as normal cuts (and delete) 00155 void addCuts(OsiCuts & cs); 00156 private: 00157 OsiRowCut2 ** rowCut_; 00159 CoinHashLink *hash_; 00160 int size_; 00161 int hashMultiplier_; 00162 int numberCuts_; 00163 int lastHash_; 00164 }; 00165 #endif 00166