DecompVar.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef DECOMP_VAR_INCLUDED
00017 #define DECOMP_VAR_INCLUDED
00018
00019 #include "DecompPortable.h"
00020 #include "UtilHash.h"
00021
00022 #include <iostream>
00023 using namespace std;
00024
00025 class DecompApp;
00026
00027
00028 class DecompVar {
00029 private:
00030 DecompVar(const DecompVar&);
00031 DecompVar& operator=(const DecompVar&);
00032
00033 public:
00034
00035
00036 CoinPackedVector m_s;
00037
00038 private:
00039
00040 double m_origCost;
00041 double m_redCost;
00042 int m_effCnt;
00043 string m_strHash;
00044
00045 public:
00046 inline double getOriginalCost() const {
00047 return m_origCost;
00048 }
00049 inline double getReducedCost() const {
00050 return m_redCost;
00051 }
00052 inline double getEffectiveness() const {
00053 return m_effCnt;
00054 }
00055 inline double getLowerBound() const {
00056 return 0.0;
00057 }
00058 inline double getUpperBound() const {
00059 return DecompInf;
00060 }
00061 inline string getStrHash() const {
00062 return m_strHash;
00063 }
00064
00065 inline void setReducedCost(const double redCost) {
00066 m_redCost = redCost;
00067 }
00068 bool isEquivalent(const DecompVar& dvar) {
00069 return m_s.isEquivalent(dvar.m_s);
00070 }
00071
00072 void fillDenseArr(int len,
00073 double* arr);
00074
00075 public:
00076 virtual void print(ostream* os = &cout,
00077 DecompApp* app = 0) const;
00078
00079 public:
00080 DecompVar(const vector<int> & ind,
00081 const vector<double> & els,
00082 const double redCost,
00083 const double origCost) :
00084 m_s (),
00085 m_origCost(origCost),
00086 m_redCost (redCost),
00087 m_effCnt (0),
00088 m_strHash () {
00089 if (ind.size() > 0) {
00090 m_s.setVector(static_cast<int>(ind.size()),
00091 &ind[0], &els[0], DECOMP_TEST_DUPINDEX);
00092 m_strHash = UtilCreateStringHash(static_cast<int>(ind.size()),
00093 &ind[0], &els[0]);
00094 }
00095 }
00096
00097 DecompVar(const int len,
00098 const int* ind,
00099 const double* els,
00100 const double redCost,
00101 const double origCost) :
00102 m_s (),
00103 m_origCost(origCost),
00104 m_redCost (redCost),
00105 m_effCnt (0),
00106 m_strHash () {
00107 if (len > 0) {
00108 m_s.setVector(len, ind, els, DECOMP_TEST_DUPINDEX);
00109 m_strHash = UtilCreateStringHash(len, ind, els);
00110 }
00111 }
00112
00113 DecompVar(const int denseLen,
00114 const double* denseArray,
00115 const double redCost,
00116 const double origCost) :
00117 m_s (DECOMP_TEST_DUPINDEX),
00118 m_origCost(origCost),
00119 m_redCost (redCost),
00120 m_effCnt (0),
00121 m_strHash () {
00122 UtilPackedVectorFromDense(denseLen, denseArray, DecompEpsilon, m_s);
00123
00124 if (m_s.getNumElements() > 0) {
00125 m_strHash = UtilCreateStringHash(denseLen, denseArray);
00126 }
00127 }
00128
00129 virtual ~DecompVar() {};
00130 };
00131
00132 #endif