Dip-All  0.91.0
GAP_Instance.h
Go to the documentation of this file.
1 //===========================================================================//
2 // This file is part of the Decomp Solver Framework. //
3 // //
4 // Decomp is distributed under the Common Public License as part of the //
5 // COIN-OR repository (http://www.coin-or.org). //
6 // //
7 // Author: Matthew Galati, Lehigh University //
8 // //
9 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, and Ted Ralphs//
10 // All Rights Reserved. //
11 //===========================================================================//
12 
13 #ifndef GAP_INSTANCE_INCLUDED
14 #define GAP_INSTANCE_INCLUDED
15 
16 //===========================================================================//
17 #include "UtilMacros.h"
18 
19 using namespace std;
20 
21 //===========================================================================//
42 //===========================================================================//
43 class GAP_Instance {
44 
45 private:
47  int m_nTasks; //n (use j index)
48  int m_nMachines; //m (use i index)
49  int* m_capacity; //b[i = 1..m]
50  int* m_profit; //p[i,j]
51  int* m_weight; //w[i,j]
52 
55  double m_bestKnownLB;
56  double m_bestKnownUB;
57 
58 
59 public:
61  inline const int getNTasks () const {
62  return m_nTasks;
63  }
64  inline const int getNMachines() const {
65  return m_nMachines;
66  }
67  inline const int* getCapacity () const {
68  return m_capacity;
69  }
70  inline const int* getProfit () const {
71  return m_profit;
72  }
73  inline const int* getWeight () const {
74  return m_weight;
75  }
76 
77 public:
79  void readInstance(string& filename);
80  void readBestKnown(string& fileName,
81  string& instanceName);
82 
83  inline void initMembers() {
84  m_nTasks = 0;
85  m_nMachines = 0;
86  m_capacity = NULL;
87  m_profit = NULL;
88  m_weight = NULL;
89  m_isProvenOptimal = false;
90  m_bestKnownLB = -1.e20;
91  m_bestKnownUB = 1.e20;
92  }
93 
94  inline const int getIndexIJ(const int i,
95  const int j) const {
96  return (i * m_nTasks) + j;
97  }
98 
99  inline pair<int, int> getIndexInv(const int index) const {
100  return make_pair(index / m_nTasks, index % m_nTasks);
101  }
102 
103  inline const double getBestKnownLB() const {
104  return m_bestKnownLB;
105  }
106  inline const double getBestKnownUB() const {
107  return m_bestKnownUB;
108  }
109 
110 public:
115  initMembers();
116  };
117 
119  GAP_Instance(string& fileName) {
120  initMembers();
121  readInstance(fileName);
122  }
123 
125  UTIL_DELARR(m_capacity);
126  UTIL_DELARR(m_profit);
127  UTIL_DELARR(m_weight);
128  };
129 };
130 
131 #endif
pair< int, int > getIndexInv(const int index) const
Definition: GAP_Instance.h:99
~GAP_Instance()
Default constructor.
Definition: GAP_Instance.h:124
void initMembers()
Definition: GAP_Instance.h:83
const int getNTasks() const
Definition: GAP_Instance.h:61
#define UTIL_DELARR(x)
Definition: UtilMacros.h:29
double m_bestKnownUB
Definition: GAP_Instance.h:56
const int * getWeight() const
Definition: GAP_Instance.h:73
GAP_Instance(string &fileName)
Default constructor.
Definition: GAP_Instance.h:119
int * m_capacity
Definition: GAP_Instance.h:49
GAP_Instance()
Default constructor.
Definition: GAP_Instance.h:114
const double getBestKnownLB() const
Definition: GAP_Instance.h:103
const int getIndexIJ(const int i, const int j) const
Definition: GAP_Instance.h:94
const int getNMachines() const
Definition: GAP_Instance.h:64
double m_bestKnownLB
Definition: GAP_Instance.h:55
const int * getProfit() const
Definition: GAP_Instance.h:70
bool m_isProvenOptimal
GAP_Instance best known LB/UB.
Definition: GAP_Instance.h:54
int m_nTasks
GAP_Instance problem instance data.
Definition: GAP_Instance.h:47
const double getBestKnownUB() const
Definition: GAP_Instance.h:106
int * m_profit
Definition: GAP_Instance.h:50
const int * getCapacity() const
Definition: GAP_Instance.h:67
int * m_weight
Definition: GAP_Instance.h:51