Cgl  0.60.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OsiCut.hpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 // This code is licensed under the terms of the Eclipse Public License (EPL).
4 
5 #ifndef OsiCut_H
6 #define OsiCut_H
7 
8 #include "OsiCollections.hpp"
9 #include "OsiSolverInterface.hpp"
10 
19 /*
20  COIN_NOTEST_DUPLICATE is rooted in CoinUtils. Check there before you
21  meddle here.
22 */
23 #ifdef COIN_FAST_CODE
24 #ifndef COIN_NOTEST_DUPLICATE
25 #define COIN_NOTEST_DUPLICATE
26 #endif
27 #endif
28 
29 #ifndef COIN_NOTEST_DUPLICATE
30 #define COIN_DEFAULT_VALUE_FOR_DUPLICATE true
31 #else
32 #define COIN_DEFAULT_VALUE_FOR_DUPLICATE false
33 #endif
34 
35 class OsiCut {
36 
37 public:
38  //-------------------------------------------------------------------
41  inline void setEffectiveness(double e);
44  inline double effectiveness() const;
46 
49  inline void setGloballyValid(bool trueFalse)
51  {
52  globallyValid_ = trueFalse ? 1 : 0;
53  }
54  inline void setGloballyValid()
55  {
56  globallyValid_ = 1;
57  }
58  inline void setNotGloballyValid()
59  {
60  globallyValid_ = 0;
61  }
63  inline bool globallyValid() const
64  {
65  return globallyValid_ != 0;
66  }
68  inline void setGloballyValidAsInteger(int trueFalse)
69  {
70  globallyValid_ = trueFalse;
71  }
73  inline int globallyValidAsInteger() const
74  {
75  return globallyValid_;
76  }
78 
81  virtual void print() const {}
84 
85 #if 0
86  / **@name Times used */
87  / /@{
88  / // Set times used
89  inline void setTimesUsed( int t );
90  / // Increment times used
91  inline void incrementTimesUsed();
92  / // Get times used
93  inline int timesUsed() const;
94  / /@}
95 
96  / **@name Times tested */
97  / /@{
98  / // Set times tested
99  inline void setTimesTested( int t );
100  / // Increment times tested
101  inline void incrementTimesTested();
102  / // Get times tested
103  inline int timesTested() const;
104  / /@}
105 #endif
106 
107  //----------------------------------------------------------------
108 
111  inline virtual bool operator==(const OsiCut &rhs) const;
114  inline virtual bool operator!=(const OsiCut &rhs) const;
116  inline virtual bool operator<(const OsiCut &rhs) const;
118  inline virtual bool operator>(const OsiCut &rhs) const;
120 
121  //----------------------------------------------------------------
122  // consistent() - returns true if the cut is consistent with repect to itself.
123  // This might include checks to ensure that a packed vector
124  // itself does not have a negative index.
125  // consistent(const OsiSolverInterface& si) - returns true if cut is consistent with
126  // respect to the solver interface's model. This might include a check to
127  // make sure a column index is not greater than the number
128  // of columns in the problem.
129  // infeasible(const OsiSolverInterface& si) - returns true if the cut is infeasible
130  // "with respect to itself". This might include a check to ensure
131  // the lower bound is greater than the upper bound, or if the
132  // cut simply replaces bounds that the new bounds are feasible with
133  // respect to the old bounds.
134  //-----------------------------------------------------------------
142  inline virtual bool consistent() const = 0;
143 
149  inline virtual bool consistent(const OsiSolverInterface &si) const = 0;
150 
172  inline virtual bool infeasible(const OsiSolverInterface &si) const = 0;
173 
178  virtual double violated(const double *solution) const = 0;
180 
181 protected:
184  OsiCut();
186 
188  OsiCut(const OsiCut &);
189 
191  OsiCut &operator=(const OsiCut &rhs);
192 
194  virtual ~OsiCut();
196 
197 private:
200  double effectiveness_;
204 #if 0
205  int timesUsed_;
208  int timesTested_;
209 #endif
210 
211 };
212 
213 //-------------------------------------------------------------------
214 // Set/Get member data
215 //-------------------------------------------------------------------
217 double OsiCut::effectiveness() const { return effectiveness_; }
218 
219 #if 0
220 void OsiCut::setTimesUsed( int t ) { timesUsed_=t; }
221 void OsiCut::incrementTimesUsed() { timesUsed_++; }
222 int OsiCut::timesUsed() const { return timesUsed_; }
223 
224 void OsiCut::setTimesTested( int t ) { timesTested_=t; }
225 void OsiCut::incrementTimesTested() { timesTested_++; }
226 int OsiCut::timesTested() const{ return timesTested_; }
227 #endif
228 
229 //----------------------------------------------------------------
230 // == operator
231 //-------------------------------------------------------------------
232 bool OsiCut::operator==(const OsiCut &rhs) const
233 {
234  return effectiveness() == rhs.effectiveness();
235 }
236 bool OsiCut::operator!=(const OsiCut &rhs) const
237 {
238  return !((*this) == rhs);
239 }
240 bool OsiCut::operator<(const OsiCut &rhs) const
241 {
242  return effectiveness() < rhs.effectiveness();
243 }
244 bool OsiCut::operator>(const OsiCut &rhs) const
245 {
246  return effectiveness() > rhs.effectiveness();
247 }
248 #endif
249 
250 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
251 */
virtual ~OsiCut()
Destructor.
void setEffectiveness(double e)
Set effectiveness.
Definition: OsiCut.hpp:216
OsiCut & operator=(const OsiCut &rhs)
Assignment operator.
virtual bool operator==(const OsiCut &rhs) const
equal. 2 cuts are equal if there effectiveness are equal
Definition: OsiCut.hpp:232
double effectiveness() const
Get effectiveness.
Definition: OsiCut.hpp:217
void setNotGloballyValid()
Definition: OsiCut.hpp:58
virtual bool operator>(const OsiCut &rhs) const
less than. True if this.effectiveness &gt; rhs.effectiveness
Definition: OsiCut.hpp:244
double effectiveness_
Effectiveness.
Definition: OsiCut.hpp:201
Abstract Base Class for describing an interface to a solver.
void setGloballyValid()
Definition: OsiCut.hpp:54
void setGloballyValidAsInteger(int trueFalse)
Set globallyValid as integer (nonzero true)
Definition: OsiCut.hpp:68
virtual bool infeasible(const OsiSolverInterface &si) const =0
Returns true if the cut is infeasible &quot;with respect to itself&quot; and cannot be satisfied.
virtual bool operator<(const OsiCut &rhs) const
less than. True if this.effectiveness &lt; rhs.effectiveness
Definition: OsiCut.hpp:240
virtual void print() const
Print cuts in collection.
Definition: OsiCut.hpp:82
virtual bool consistent() const =0
Returns true if the cut is consistent with respect to itself, without considering any data in the mod...
bool globallyValid() const
Get globallyValid.
Definition: OsiCut.hpp:63
virtual bool operator!=(const OsiCut &rhs) const
not equal
Definition: OsiCut.hpp:236
int globallyValid_
If cut has global validity i.e. can be used anywhere in tree.
Definition: OsiCut.hpp:203
OsiCut()
Default Constructor.
int globallyValidAsInteger() const
Get globallyValid.
Definition: OsiCut.hpp:73
virtual double violated(const double *solution) const =0
Returns infeasibility of the cut with respect to solution passed in i.e.