Osi 0.108.9
Loading...
Searching...
No Matches
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"
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
35class OsiCut {
36
37public:
38 //-------------------------------------------------------------------
41
42 inline void setEffectiveness(double e);
44 inline double effectiveness() const;
46
50 inline void setGloballyValid(bool trueFalse)
51 {
52 globallyValid_ = trueFalse ? 1 : 0;
53 }
54 inline void setGloballyValid()
55 {
57 }
58 inline void setNotGloballyValid()
59 {
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
82 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
112 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
181protected:
186
188 OsiCut(const OsiCut &);
189
191 OsiCut &operator=(const OsiCut &rhs);
192
194 virtual ~OsiCut();
196
197private:
204#if 0
206 int timesUsed_;
208 int timesTested_;
209#endif
211};
212
213//-------------------------------------------------------------------
214// Set/Get member data
215//-------------------------------------------------------------------
217double OsiCut::effectiveness() const { return effectiveness_; }
218
219#if 0
220void OsiCut::setTimesUsed( int t ) { timesUsed_=t; }
221void OsiCut::incrementTimesUsed() { timesUsed_++; }
222int OsiCut::timesUsed() const { return timesUsed_; }
223
224void OsiCut::setTimesTested( int t ) { timesTested_=t; }
225void OsiCut::incrementTimesTested() { timesTested_++; }
226int OsiCut::timesTested() const{ return timesTested_; }
227#endif
228
229//----------------------------------------------------------------
230// == operator
231//-------------------------------------------------------------------
232bool OsiCut::operator==(const OsiCut &rhs) const
233{
234 return effectiveness() == rhs.effectiveness();
235}
236bool OsiCut::operator!=(const OsiCut &rhs) const
237{
238 return !((*this) == rhs);
239}
240bool OsiCut::operator<(const OsiCut &rhs) const
241{
242 return effectiveness() < rhs.effectiveness();
243}
244bool 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*/
OsiCut(const OsiCut &)
Copy constructor.
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
int globallyValid_
If cut has global validity i.e. can be used anywhere in tree.
Definition OsiCut.hpp:203
virtual bool infeasible(const OsiSolverInterface &si) const =0
Returns true if the cut is infeasible "with respect to itself" and cannot be satisfied.
virtual bool operator>(const OsiCut &rhs) const
less than. True if this.effectiveness > rhs.effectiveness
Definition OsiCut.hpp:244
virtual double violated(const double *solution) const =0
Returns infeasibility of the cut with respect to solution passed in i.e.
virtual bool consistent() const =0
Returns true if the cut is consistent with respect to itself, without considering any data in the mod...
virtual bool operator<(const OsiCut &rhs) const
less than. True if this.effectiveness < rhs.effectiveness
Definition OsiCut.hpp:240
virtual ~OsiCut()
Destructor.
void setNotGloballyValid()
Definition OsiCut.hpp:58
int globallyValidAsInteger() const
Get globallyValid.
Definition OsiCut.hpp:73
void setEffectiveness(double e)
Set effectiveness.
Definition OsiCut.hpp:216
void setGloballyValid()
Definition OsiCut.hpp:54
double effectiveness_
Effectiveness.
Definition OsiCut.hpp:201
double effectiveness() const
Get effectiveness.
Definition OsiCut.hpp:217
void setGloballyValid(bool trueFalse)
Set globallyValid (nonzero true)
Definition OsiCut.hpp:50
virtual void print() const
Print cuts in collection.
Definition OsiCut.hpp:82
OsiCut()
Default Constructor.
void setGloballyValidAsInteger(int trueFalse)
Set globallyValid as integer (nonzero true)
Definition OsiCut.hpp:68
bool globallyValid() const
Get globallyValid.
Definition OsiCut.hpp:63
virtual bool operator!=(const OsiCut &rhs) const
not equal
Definition OsiCut.hpp:236
virtual bool consistent(const OsiSolverInterface &si) const =0
Returns true if cut is consistent when considering the solver interface's model.
Abstract Base Class for describing an interface to a solver.