/usr/include/coin/OsiCut.hpp is in coinor-libosi-dev 0.106.9-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | // Copyright (C) 2000, International Business Machines
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
#ifndef OsiCut_H
#define OsiCut_H
#include "OsiCollections.hpp"
#include "OsiSolverInterface.hpp"
/** Base Class for cut.
The Base cut class contains:
<ul>
<li>a measure of the cut's effectivness
</ul>
*/
/*
COIN_NOTEST_DUPLICATE is rooted in CoinUtils. Check there before you
meddle here.
*/
#ifdef COIN_FAST_CODE
#ifndef COIN_NOTEST_DUPLICATE
#define COIN_NOTEST_DUPLICATE
#endif
#endif
#ifndef COIN_NOTEST_DUPLICATE
#define COIN_DEFAULT_VALUE_FOR_DUPLICATE true
#else
#define COIN_DEFAULT_VALUE_FOR_DUPLICATE false
#endif
class OsiCut {
public:
//-------------------------------------------------------------------
/**@name Effectiveness */
//@{
/// Set effectiveness
inline void setEffectiveness( double e );
/// Get effectiveness
inline double effectiveness() const;
//@}
/**@name GloballyValid */
//@{
/// Set globallyValid (nonzero true)
inline void setGloballyValid( bool trueFalse )
{ globallyValid_=trueFalse ? 1 : 0;}
inline void setGloballyValid( )
{ globallyValid_=1;}
inline void setNotGloballyValid( )
{ globallyValid_=0;}
/// Get globallyValid
inline bool globallyValid() const
{ return globallyValid_!=0;}
/// Set globallyValid as integer (nonzero true)
inline void setGloballyValidAsInteger( int trueFalse )
{ globallyValid_=trueFalse;}
/// Get globallyValid
inline int globallyValidAsInteger() const
{ return globallyValid_;}
//@}
/**@name Debug stuff */
//@{
/// Print cuts in collection
virtual void print() const {}
//@}
#if 0
/ **@name Times used */
/ /@{
/ // Set times used
inline void setTimesUsed( int t );
/ // Increment times used
inline void incrementTimesUsed();
/ // Get times used
inline int timesUsed() const;
/ /@}
/ **@name Times tested */
/ /@{
/ // Set times tested
inline void setTimesTested( int t );
/ // Increment times tested
inline void incrementTimesTested();
/ // Get times tested
inline int timesTested() const;
/ /@}
#endif
//----------------------------------------------------------------
/**@name Comparison operators */
//@{
///equal. 2 cuts are equal if there effectiveness are equal
inline virtual bool operator==(const OsiCut& rhs) const;
/// not equal
inline virtual bool operator!=(const OsiCut& rhs) const;
/// less than. True if this.effectiveness < rhs.effectiveness
inline virtual bool operator< (const OsiCut& rhs) const;
/// less than. True if this.effectiveness > rhs.effectiveness
inline virtual bool operator> (const OsiCut& rhs) const;
//@}
//----------------------------------------------------------------
// consistent() - returns true if the cut is consistent with repect to itself.
// This might include checks to ensure that a packed vector
// itself does not have a negative index.
// consistent(const OsiSolverInterface& si) - returns true if cut is consistent with
// respect to the solver interface's model. This might include a check to
// make sure a column index is not greater than the number
// of columns in the problem.
// infeasible(const OsiSolverInterface& si) - returns true if the cut is infeasible
// "with respect to itself". This might include a check to ensure
// the lower bound is greater than the upper bound, or if the
// cut simply replaces bounds that the new bounds are feasible with
// respect to the old bounds.
//-----------------------------------------------------------------
/**@name Sanity checks on cut */
//@{
/** Returns true if the cut is consistent with respect to itself,
without considering any
data in the model. For example, it might check to ensure
that a column index is not negative.
*/
inline virtual bool consistent() const=0;
/** Returns true if cut is consistent when considering the solver
interface's model. For example, it might check to ensure
that a column index is not greater than the number of columns
in the model. Assumes consistent() is true.
*/
inline virtual bool consistent(const OsiSolverInterface& si) const=0;
/** Returns true if the cut is infeasible "with respect to itself" and
cannot be satisfied. This method does NOT check whether adding the
cut to the solver interface's model will make the -model- infeasble.
A cut which returns !infeasible(si) may very well make the model
infeasible. (Of course, adding a cut with returns infeasible(si)
will make the model infeasible.)
The "with respect to itself" is in quotes becaues
in the case where the cut
simply replaces existing bounds, it may make
sense to test infeasibility with respect to the current bounds
held in the solver interface's model. For example, if the cut
has a single variable in it, it might check that the maximum
of new and existing lower bounds is greater than the minium of
the new and existing upper bounds.
Assumes that consistent(si) is true.<br>
Infeasible cuts can be a useful mechanism for a cut generator to
inform the solver interface that its detected infeasibility of the
problem.
*/
inline virtual bool infeasible(const OsiSolverInterface &si) const=0;
/** Returns infeasibility of the cut with respect to solution
passed in i.e. is positive if cuts off that solution.
solution is getNumCols() long..
*/
virtual double violated(const double * solution) const=0;
//@}
protected:
/**@name Constructors and destructors */
//@{
/// Default Constructor
OsiCut ();
/// Copy constructor
OsiCut ( const OsiCut &);
/// Assignment operator
OsiCut & operator=( const OsiCut& rhs);
/// Destructor
virtual ~OsiCut ();
//@}
private:
/**@name Private member data */
//@{
/// Effectiveness
double effectiveness_;
/// If cut has global validity i.e. can be used anywhere in tree
int globallyValid_;
#if 0
/// Times used
int timesUsed_;
/// Times tested
int timesTested_;
#endif
//@}
};
//-------------------------------------------------------------------
// Set/Get member data
//-------------------------------------------------------------------
void OsiCut::setEffectiveness(double e) { effectiveness_=e; }
double OsiCut::effectiveness() const { return effectiveness_; }
#if 0
void OsiCut::setTimesUsed( int t ) { timesUsed_=t; }
void OsiCut::incrementTimesUsed() { timesUsed_++; }
int OsiCut::timesUsed() const { return timesUsed_; }
void OsiCut::setTimesTested( int t ) { timesTested_=t; }
void OsiCut::incrementTimesTested() { timesTested_++; }
int OsiCut::timesTested() const{ return timesTested_; }
#endif
//----------------------------------------------------------------
// == operator
//-------------------------------------------------------------------
bool
OsiCut::operator==(const OsiCut& rhs) const
{
return effectiveness()==rhs.effectiveness();
}
bool
OsiCut::operator!=(const OsiCut& rhs) const
{
return !( (*this)==rhs );
}
bool
OsiCut::operator< (const OsiCut& rhs) const
{
return effectiveness()<rhs.effectiveness();
}
bool
OsiCut::operator> (const OsiCut& rhs) const
{
return effectiveness()>rhs.effectiveness();
}
#endif
|