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