00001 // Copyright (C) 2000, International Business Machines 00002 // Corporation and others. All Rights Reserved. 00003 #ifndef OsiCut_H 00004 #define OsiCut_H 00005 00006 #include "OsiCollections.hpp" 00007 #include "OsiSolverInterface.hpp" 00008 00017 #if 0 00018 / // count of how many times the cut has been used 00019 / // count of how many times the cut has been tested 00020 #endif 00021 00022 00023 class OsiCut { 00024 00025 public: 00026 00027 //------------------------------------------------------------------- 00030 00031 inline void setEffectiveness( double e ); 00033 inline double effectiveness() const; 00035 00038 00039 inline void setGloballyValid( bool trueFalse ) 00040 { globallyValid_=trueFalse;}; 00041 inline void setGloballyValid( ) 00042 { globallyValid_=true;}; 00043 inline void setNotGloballyValid( ) 00044 { globallyValid_=false;}; 00046 inline bool globallyValid() const 00047 { return globallyValid_;}; 00049 00052 00053 virtual void print() const {}; 00055 00056 #if 0 00057 / **@name Times used */ 00058 / /@{ 00059 / // Set times used 00060 inline void setTimesUsed( int t ); 00061 / // Increment times used 00062 inline void incrementTimesUsed(); 00063 / // Get times used 00064 inline int timesUsed() const; 00065 / /@} 00066 00067 / **@name Times tested */ 00068 / /@{ 00069 / // Set times tested 00070 inline void setTimesTested( int t ); 00071 / // Increment times tested 00072 inline void incrementTimesTested(); 00073 / // Get times tested 00074 inline int timesTested() const; 00075 / /@} 00076 #endif 00077 00078 //---------------------------------------------------------------- 00079 00082 00083 inline virtual bool operator==(const OsiCut& rhs) const; 00085 inline virtual bool operator!=(const OsiCut& rhs) const; 00087 inline virtual bool operator< (const OsiCut& rhs) const; 00089 inline virtual bool operator> (const OsiCut& rhs) const; 00091 00092 //---------------------------------------------------------------- 00093 // consistent() - returns true if the cut is consistent with repect to itself. 00094 // This might include checks to ensure that a packed vector 00095 // itself does not have a negative index. 00096 // consistent(const OsiSolverInterface& si) - returns true if cut is consistent with 00097 // respect to the solver interface's model. This might include a check to 00098 // make sure a column index is not greater than the number 00099 // of columns in the problem. 00100 // infeasible(const OsiSolverInterface& si) - returns true if the cut is infeasible 00101 // "with respect to itself". This might include a check to ensure 00102 // the lower bound is greater than the upper bound, or if the 00103 // cut simply replaces bounds that the new bounds are feasible with 00104 // respect to the old bounds. 00105 //----------------------------------------------------------------- 00113 inline virtual bool consistent() const=0; 00114 00120 inline virtual bool consistent(const OsiSolverInterface& si) const=0; 00121 00143 inline virtual bool infeasible(const OsiSolverInterface &si) const=0; 00144 00149 virtual double violated(const double * solution) const=0; 00151 00152 protected: 00153 00156 00157 OsiCut (); 00158 00160 OsiCut ( const OsiCut &); 00161 00163 OsiCut & operator=( const OsiCut& rhs); 00164 00166 virtual ~OsiCut (); 00168 00169 private: 00170 00173 00174 double effectiveness_; 00176 bool globallyValid_; 00177 #if 0 00179 int timesUsed_; 00181 int timesTested_; 00182 #endif 00183 00184 }; 00185 00186 00187 //------------------------------------------------------------------- 00188 // Set/Get member data 00189 //------------------------------------------------------------------- 00190 void OsiCut::setEffectiveness(double e) { effectiveness_=e; } 00191 double OsiCut::effectiveness() const { return effectiveness_; } 00192 00193 #if 0 00194 void OsiCut::setTimesUsed( int t ) { timesUsed_=t; } 00195 void OsiCut::incrementTimesUsed() { timesUsed_++; } 00196 int OsiCut::timesUsed() const { return timesUsed_; } 00197 00198 void OsiCut::setTimesTested( int t ) { timesTested_=t; } 00199 void OsiCut::incrementTimesTested() { timesTested_++; } 00200 int OsiCut::timesTested() const{ return timesTested_; } 00201 #endif 00202 00203 //---------------------------------------------------------------- 00204 // == operator 00205 //------------------------------------------------------------------- 00206 bool 00207 OsiCut::operator==(const OsiCut& rhs) const 00208 { 00209 return effectiveness()==rhs.effectiveness(); 00210 } 00211 bool 00212 OsiCut::operator!=(const OsiCut& rhs) const 00213 { 00214 return !( (*this)==rhs ); 00215 } 00216 bool 00217 OsiCut::operator< (const OsiCut& rhs) const 00218 { 00219 return effectiveness()<rhs.effectiveness(); 00220 } 00221 bool 00222 OsiCut::operator> (const OsiCut& rhs) const 00223 { 00224 return effectiveness()>rhs.effectiveness(); 00225 } 00226 #endif