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-2007, Lehigh University, Matthew Galati, and Ted Ralphs// 00010 // All Rights Reserved. // 00011 //===========================================================================// 00012 00013 #ifndef GAP_INSTANCE_INCLUDED 00014 #define GAP_INSTANCE_INCLUDED 00015 00016 //===========================================================================// 00017 #include "UtilMacros.h" 00018 00019 using namespace std; 00020 00021 //===========================================================================// 00042 //===========================================================================// 00043 class GAP_Instance { 00044 00045 private: 00047 int m_nTasks; //n (use j index) 00048 int m_nMachines; //m (use i index) 00049 int* m_capacity; //b[i = 1..m] 00050 int* m_profit; //p[i,j] 00051 int* m_weight; //w[i,j] 00052 00054 bool m_isProvenOptimal; 00055 double m_bestKnownLB; 00056 double m_bestKnownUB; 00057 00058 00059 public: 00061 inline const int getNTasks () const { 00062 return m_nTasks; 00063 } 00064 inline const int getNMachines() const { 00065 return m_nMachines; 00066 } 00067 inline const int* getCapacity () const { 00068 return m_capacity; 00069 } 00070 inline const int* getProfit () const { 00071 return m_profit; 00072 } 00073 inline const int* getWeight () const { 00074 return m_weight; 00075 } 00076 00077 public: 00079 void readInstance(string& filename); 00080 void readBestKnown(string& fileName, 00081 string& instanceName); 00082 00083 inline void initMembers() { 00084 m_nTasks = 0; 00085 m_nMachines = 0; 00086 m_capacity = NULL; 00087 m_profit = NULL; 00088 m_weight = NULL; 00089 m_isProvenOptimal = false; 00090 m_bestKnownLB = -1.e20; 00091 m_bestKnownUB = 1.e20; 00092 } 00093 00094 inline const int getIndexIJ(const int i, 00095 const int j) const { 00096 return (i * m_nTasks) + j; 00097 } 00098 00099 inline pair<int, int> getIndexInv(const int index) const { 00100 return make_pair(index / m_nTasks, index % m_nTasks); 00101 } 00102 00103 inline const double getBestKnownLB() const { 00104 return m_bestKnownLB; 00105 } 00106 inline const double getBestKnownUB() const { 00107 return m_bestKnownUB; 00108 } 00109 00110 public: 00114 GAP_Instance() { 00115 initMembers(); 00116 }; 00117 00119 GAP_Instance(string& fileName) { 00120 initMembers(); 00121 readInstance(fileName); 00122 } 00123 00124 ~GAP_Instance() { 00125 UTIL_DELARR(m_capacity); 00126 UTIL_DELARR(m_profit); 00127 UTIL_DELARR(m_weight); 00128 }; 00129 }; 00130 00131 #endif