OsiCut.hpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #ifndef OsiCut_H
4 #define OsiCut_H
5 
6 #include "OsiCollections.hpp"
7 #include "OsiSolverInterface.hpp"
8 
17 #if 0
18 / // count of how many times the cut has been used
19 / // count of how many times the cut has been tested
20 #endif
21 
22 #ifndef COIN_NOTEST_DUPLICATE
23 #define COIN_DEFAULT_VALUE_FOR_DUPLICATE true
24 #else
25 #define COIN_DEFAULT_VALUE_FOR_DUPLICATE false
26 #endif
27 
28 
29 class OsiCut {
30 
31 public:
32 
33  //-------------------------------------------------------------------
36 
37  inline void setEffectiveness( double e );
39  inline double effectiveness() const;
41 
44 
45  inline void setGloballyValid( bool trueFalse )
46  { globallyValid_=trueFalse ? 1 : 0;}
47  inline void setGloballyValid( )
48  { globallyValid_=1;}
49  inline void setNotGloballyValid( )
50  { globallyValid_=0;}
52  inline bool globallyValid() const
53  { return globallyValid_!=0;}
55  inline void setGloballyValidAsInteger( int trueFalse )
56  { globallyValid_=trueFalse;}
58  inline int globallyValidAsInteger() const
59  { return globallyValid_;}
61 
64 
65  virtual void print() const {}
67 
68 #if 0
69  / **@name Times used */
70  / /@{
71  / // Set times used
72  inline void setTimesUsed( int t );
73  / // Increment times used
74  inline void incrementTimesUsed();
75  / // Get times used
76  inline int timesUsed() const;
77  / /@}
78 
79  / **@name Times tested */
80  / /@{
81  / // Set times tested
82  inline void setTimesTested( int t );
83  / // Increment times tested
84  inline void incrementTimesTested();
85  / // Get times tested
86  inline int timesTested() const;
87  / /@}
88 #endif
89 
90  //----------------------------------------------------------------
91 
94 
95  inline virtual bool operator==(const OsiCut& rhs) const;
97  inline virtual bool operator!=(const OsiCut& rhs) const;
99  inline virtual bool operator< (const OsiCut& rhs) const;
101  inline virtual bool operator> (const OsiCut& rhs) const;
103 
104  //----------------------------------------------------------------
105  // consistent() - returns true if the cut is consistent with repect to itself.
106  // This might include checks to ensure that a packed vector
107  // itself does not have a negative index.
108  // consistent(const OsiSolverInterface& si) - returns true if cut is consistent with
109  // respect to the solver interface's model. This might include a check to
110  // make sure a column index is not greater than the number
111  // of columns in the problem.
112  // infeasible(const OsiSolverInterface& si) - returns true if the cut is infeasible
113  // "with respect to itself". This might include a check to ensure
114  // the lower bound is greater than the upper bound, or if the
115  // cut simply replaces bounds that the new bounds are feasible with
116  // respect to the old bounds.
117  //-----------------------------------------------------------------
125  inline virtual bool consistent() const=0;
126 
132  inline virtual bool consistent(const OsiSolverInterface& si) const=0;
133 
155  inline virtual bool infeasible(const OsiSolverInterface &si) const=0;
156 
161  virtual double violated(const double * solution) const=0;
163 
164 protected:
165 
168 
169  OsiCut ();
170 
172  OsiCut ( const OsiCut &);
173 
175  OsiCut & operator=( const OsiCut& rhs);
176 
178  virtual ~OsiCut ();
180 
181 private:
182 
185 
189 #if 0
190 
191  int timesUsed_;
193  int timesTested_;
194 #endif
195 
196 };
197 
198 
199 //-------------------------------------------------------------------
200 // Set/Get member data
201 //-------------------------------------------------------------------
203 double OsiCut::effectiveness() const { return effectiveness_; }
204 
205 #if 0
206 void OsiCut::setTimesUsed( int t ) { timesUsed_=t; }
207 void OsiCut::incrementTimesUsed() { timesUsed_++; }
208 int OsiCut::timesUsed() const { return timesUsed_; }
209 
210 void OsiCut::setTimesTested( int t ) { timesTested_=t; }
211 void OsiCut::incrementTimesTested() { timesTested_++; }
212 int OsiCut::timesTested() const{ return timesTested_; }
213 #endif
214 
215 //----------------------------------------------------------------
216 // == operator
217 //-------------------------------------------------------------------
218 bool
219 OsiCut::operator==(const OsiCut& rhs) const
220 {
221  return effectiveness()==rhs.effectiveness();
222 }
223 bool
224 OsiCut::operator!=(const OsiCut& rhs) const
225 {
226  return !( (*this)==rhs );
227 }
228 bool
229 OsiCut::operator< (const OsiCut& rhs) const
230 {
231  return effectiveness()<rhs.effectiveness();
232 }
233 bool
234 OsiCut::operator> (const OsiCut& rhs) const
235 {
236  return effectiveness()>rhs.effectiveness();
237 }
238 #endif