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