00001 //===========================================================================// 00002 // This file is part of the Decomp Solver Framework. // 00003 // // 00004 // Decomp is distributed under the Common Public License as part of the // 00005 // COIN-OR repository (http://www.coin-or.org). // 00006 // // 00007 // Author: Matthew Galati, Lehigh University // 00008 // // 00009 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, and Ted Ralphs// 00010 // All Rights Reserved. // 00011 //===========================================================================// 00012 00013 #ifndef MMKP_INSTANCE_INCLUDED 00014 #define MMKP_INSTANCE_INCLUDED 00015 00016 //===========================================================================// 00017 #include "UtilMacros.h" 00018 using namespace std; 00019 //===========================================================================// 00020 class MMKP_Param; 00021 //===========================================================================// 00022 00023 //===========================================================================// 00036 //===========================================================================// 00037 class MMKP_Instance { 00038 private: 00040 int m_nKnapRows; //m 00041 int m_nGroupRows; //n 00042 int m_nGroupCols; //l 00043 double * m_capacity; //b[k = 1..m] 00044 double * m_value; //v[i,j] 00045 double ** m_weight; //r[k,i,j] 00046 00048 bool m_isProvenOptimal; 00049 double m_bestKnownLB; 00050 double m_bestKnownUB; 00051 00052 00053 public: 00055 inline const int getNKnapRows () const {return m_nKnapRows; } 00056 inline const int getNGroupRows() const {return m_nGroupRows;} 00057 inline const int getNGroupCols() const {return m_nGroupCols;} 00058 inline const double * getCapacity () const {return m_capacity; } 00059 inline const double * getValue () const {return m_value; } 00060 inline const double * const* getWeight()const {return m_weight; } 00061 00062 public: 00064 void readInstance (string & fileName, 00065 string & dataFormat); 00066 void readInstanceSimon(string & fileName); 00067 void readBestKnown(string & fileName, 00068 string & instanceName); 00069 00070 inline void initMembers(){ 00071 m_nKnapRows = 0; 00072 m_nGroupRows = 0; 00073 m_nGroupCols = 0; 00074 m_capacity = NULL; 00075 m_value = NULL; 00076 m_weight = NULL; 00077 m_isProvenOptimal = false; 00078 m_bestKnownLB = -1.e20; 00079 m_bestKnownUB = 1.e20; 00080 } 00081 00082 inline const int getIndexIJ(const int i, 00083 const int j) const{ 00084 return (i * m_nGroupCols) + j; 00085 } 00086 00087 inline pair<int,int> getIndexInv(const int index) const { 00088 return make_pair(index / m_nGroupCols, index % m_nGroupCols); 00089 } 00090 00091 inline const double getBestKnownLB() const {return m_bestKnownLB;} 00092 inline const double getBestKnownUB() const {return m_bestKnownUB;} 00093 00094 public: 00098 MMKP_Instance(){ 00099 initMembers(); 00100 }; 00101 00103 MMKP_Instance(string & fileName) { 00104 string dataFormat = "hifi"; 00105 initMembers(); 00106 readInstance(fileName, dataFormat); 00107 } 00108 00110 ~MMKP_Instance() { 00111 int k; 00112 UTIL_DELARR(m_capacity); 00113 UTIL_DELARR(m_value); 00114 for(k = 0; k < m_nKnapRows; k++) 00115 UTIL_DELARR(m_weight[k]); 00116 UTIL_DELARR(m_weight); 00117 }; 00118 }; 00119 00120 #endif