DecompCut.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef DECOMP_CUT_INCLUDED
00018 #define DECOMP_CUT_INCLUDED
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "Decomp.h"
00032 #include "UtilHash.h"
00033 #include "UtilMacros.h"
00034
00035 class DecompCut {
00036 private:
00037 double m_lb;
00038 double m_ub;
00039
00040 double m_violation;
00041 int m_effCnt;
00042
00043 protected:
00044 std::string m_strHash;
00045
00046
00047 public:
00048 inline double getLowerBound() const {
00049 return m_lb;
00050 }
00051 inline double getUpperBound() const {
00052 return m_ub;
00053 }
00054 inline double getViolation() const {
00055 return m_violation;
00056 }
00057 inline int getEffCnt() const {
00058 return m_effCnt;
00059 }
00060 inline std::string getStrHash() const {
00061 return m_strHash;
00062 }
00063
00064 public:
00065 inline void setLowerBound(const double lb) {
00066 m_lb = lb;
00067 }
00068 inline void setUpperBound(const double ub) {
00069 m_ub = ub;
00070 }
00071 inline void setViolation(const double violation) {
00072 m_violation = violation;
00073 }
00074
00075 bool calcViolation(const CoinPackedVector* row,
00076 const double* x);
00077
00078 public:
00079
00080
00081
00082
00083
00084
00085 virtual void setStringHash(CoinPackedVector* row) {
00086
00087
00088 char sense;
00089 double rhs, range;
00090 UtilBoundToSense(getLowerBound(),
00091 getUpperBound(), DecompInf,
00092 sense, rhs, range);
00093 m_strHash = UtilCreateStringHash(row->getNumElements(),
00094 row->getIndices(),
00095 row->getElements(),
00096 sense, rhs);
00097
00098
00099
00100 }
00101
00102 virtual void expandCutToRow(CoinPackedVector* row) {
00103 throw CoinError("Method was invoked but not overridden.",
00104 "expandCutToRow", "DecompCut");
00105 }
00106
00107 virtual void setBounds() {
00108 throw CoinError("Method was invoked but not overridden.",
00109 "setBounds", "DecompCut");
00110 }
00111
00112 virtual bool isSame(const DecompCut* cut) const {
00113 return false;
00114 }
00115
00116 virtual void print(std::ostream* os = &std::cout) const;
00117
00118 public:
00119 inline void resetEffCnt() {
00120 m_effCnt = 0;
00121 }
00122
00125 inline void increaseEffCnt() {
00126 m_effCnt = m_effCnt <= 0 ? 1 : m_effCnt + 1;
00127 }
00128
00131 inline void decreaseEffCnt() {
00132 m_effCnt = m_effCnt >= 0 ? -1 : m_effCnt - 1;
00133 }
00134
00135 public:
00136 DecompCut() :
00137 m_lb (0.0),
00138 m_ub (0.0),
00139 m_violation(0.0),
00140 m_effCnt (0),
00141 m_strHash () {
00142 };
00143 virtual ~DecompCut() {};
00144
00145 };
00146
00147 #endif