DecompCutOsi.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_CUTOSI_HPP
00018 #define DECOMP_CUTOSI_HPP
00019
00020
00021 #include "UtilHash.h"
00022 #include "DecompCut.h"
00023 #include "OsiRowCut.hpp"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class DecompCutOsi : public DecompCut {
00035 private:
00036 DecompCutOsi(const DecompVar&);
00037 DecompCutOsi& operator=(const DecompVar&);
00038
00039 private:
00040 OsiRowCut m_osiCut;
00041
00042
00043
00044 public:
00045
00046
00047 char sense() const {
00048 double lb_ = m_osiCut.lb();
00049 double ub_ = m_osiCut.ub();
00050
00051 if ( lb_ == ub_ ) {
00052 return 'E';
00053 } else if ( lb_ == -DecompInf && ub_ == DecompInf ) {
00054 return 'N';
00055 } else if ( lb_ == -DecompInf ) {
00056 return 'L';
00057 } else if ( ub_ == DecompInf ) {
00058 return 'G';
00059 } else {
00060 return 'R';
00061 }
00062 }
00063
00064 double rhs() const {
00065 double lb_ = m_osiCut.lb();
00066 double ub_ = m_osiCut.ub();
00067
00068 if ( lb_ == ub_ ) {
00069 return ub_;
00070 } else if ( lb_ == -DecompInf && ub_ == DecompInf ) {
00071 return 0.0;
00072 } else if ( lb_ == -DecompInf ) {
00073 return ub_;
00074 } else if ( ub_ == DecompInf ) {
00075 return lb_;
00076 } else {
00077 return ub_;
00078 }
00079 }
00080
00081 void setStringHash() {
00082
00083 m_strHash = UtilCreateStringHash(m_osiCut.row().getNumElements(),
00084 m_osiCut.row().getIndices(),
00085 m_osiCut.row().getElements(),
00086
00087 sense(),
00088
00089 rhs()
00090 );
00091
00092 }
00093 void setStringHash(CoinPackedVector* row) {
00094 m_strHash = UtilCreateStringHash(row->getNumElements(),
00095 row->getIndices(),
00096 row->getElements(),
00097
00098 sense(),
00099
00100 rhs()
00101 );
00102
00103 }
00104
00105 void setBounds() {
00106 setLowerBound(m_osiCut.lb());
00107 setUpperBound(m_osiCut.ub());
00108 }
00109
00110
00111 void expandCutToRow(CoinPackedVector* row) {
00112 row->setVector(m_osiCut.row().getNumElements(),
00113 m_osiCut.row().getIndices(),
00114 m_osiCut.row().getElements(),
00115 DECOMP_TEST_DUPINDEX);
00116
00117 }
00118
00119 public:
00120 void print(std::ostream* os = &std::cout) const {
00121 (*os).precision(2);
00122 (*os) << std::endl;
00123 const int* ind = m_osiCut.row().getIndices();
00124 const double* els = m_osiCut.row().getElements();
00125
00126 for (int i = 0; i < m_osiCut.row().getNumElements(); i++) {
00127 (*os) << " + " << els[i] << " x[" << ind[i] << "]";
00128 }
00129
00130 if (getLowerBound() < -1.0e10 / 2) {
00131 (*os) << " lb: -INF";
00132 } else {
00133 (*os) << " lb: " << getLowerBound();
00134 }
00135
00136 if (getUpperBound() > 1.0e10 / 2) {
00137 (*os) << " ub: INF";
00138 } else {
00139 (*os) << " ub: " << getUpperBound();
00140 }
00141
00142 (*os) << " vio: " << getViolation() << "\n";
00143 }
00144
00145 public:
00146 DecompCutOsi(OsiRowCut& osiCut)
00147 : DecompCut(), m_osiCut(osiCut) {
00148 setBounds();
00149 };
00150 virtual ~DecompCutOsi() {}
00151
00152 };
00153
00154 #endif