Dip  0.92.4
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 // Authors: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // Ted Ralphs, Lehigh University (ted@lehigh.edu) //
9 // Jiadong Wang, Lehigh University (jiw408@lehigh.edu) //
10 // //
11 // Copyright (C) 2002-2019, Lehigh University, Matthew Galati, and Ted Ralphs//
12 // All Rights Reserved. //
13 //===========================================================================//
14 
15 #ifndef GAP_INSTANCE_INCLUDED
16 #define GAP_INSTANCE_INCLUDED
17 
18 //===========================================================================//
19 #include "UtilMacros.h"
20 
21 using namespace std;
22 
23 //===========================================================================//
44 //===========================================================================//
45 class GAP_Instance {
46 
47 private:
49  int m_nTasks; //n (use j index)
50  int m_nMachines; //m (use i index)
51  int* m_capacity; //b[i = 1..m]
52  int* m_profit; //p[i,j]
53  int* m_weight; //w[i,j]
54 
57  double m_bestKnownLB;
58  double m_bestKnownUB;
59 
60 
61 public:
63  inline const int getNTasks () const {
64  return m_nTasks;
65  }
66  inline const int getNMachines() const {
67  return m_nMachines;
68  }
69  inline const int* getCapacity () const {
70  return m_capacity;
71  }
72  inline const int* getProfit () const {
73  return m_profit;
74  }
75  inline const int* getWeight () const {
76  return m_weight;
77  }
78 
79 public:
81  void readInstance(string& filename);
82  void readBestKnown(string& fileName,
83  string& instanceName);
84 
85  inline void initMembers() {
86  m_nTasks = 0;
87  m_nMachines = 0;
88  m_capacity = NULL;
89  m_profit = NULL;
90  m_weight = NULL;
91  m_isProvenOptimal = false;
92  m_bestKnownLB = -1.e20;
93  m_bestKnownUB = 1.e20;
94  }
95 
96  inline const int getIndexIJ(const int i,
97  const int j) const {
98  return (i * m_nTasks) + j;
99  }
100 
101  inline pair<int, int> getIndexInv(const int index) const {
102  return make_pair(index / m_nTasks, index % m_nTasks);
103  }
104 
105  inline const double getBestKnownLB() const {
106  return m_bestKnownLB;
107  }
108  inline const double getBestKnownUB() const {
109  return m_bestKnownUB;
110  }
111 
112 public:
117  initMembers();
118  };
119 
121  GAP_Instance(string& fileName) {
122  initMembers();
123  readInstance(fileName);
124  }
125 
127  UTIL_DELARR(m_capacity);
128  UTIL_DELARR(m_profit);
129  UTIL_DELARR(m_weight);
130  };
131 };
132 
133 #endif
pair< int, int > getIndexInv(const int index) const
Definition: GAP_Instance.h:101
~GAP_Instance()
Default constructor.
Definition: GAP_Instance.h:126
void initMembers()
Definition: GAP_Instance.h:85
const int getNTasks() const
Definition: GAP_Instance.h:63
#define UTIL_DELARR(x)
Definition: UtilMacros.h:29
double m_bestKnownUB
Definition: GAP_Instance.h:58
const int * getWeight() const
Definition: GAP_Instance.h:75
GAP_Instance(string &fileName)
Default constructor.
Definition: GAP_Instance.h:121
int * m_capacity
Definition: GAP_Instance.h:51
GAP_Instance()
Default constructor.
Definition: GAP_Instance.h:116
const double getBestKnownLB() const
Definition: GAP_Instance.h:105
const int getIndexIJ(const int i, const int j) const
Definition: GAP_Instance.h:96
const int getNMachines() const
Definition: GAP_Instance.h:66
double m_bestKnownLB
Definition: GAP_Instance.h:57
const int * getProfit() const
Definition: GAP_Instance.h:72
bool m_isProvenOptimal
GAP_Instance best known LB/UB.
Definition: GAP_Instance.h:56
int m_nTasks
GAP_Instance problem instance data.
Definition: GAP_Instance.h:49
const double getBestKnownUB() const
Definition: GAP_Instance.h:108
int * m_profit
Definition: GAP_Instance.h:52
const int * getCapacity() const
Definition: GAP_Instance.h:69
int * m_weight
Definition: GAP_Instance.h:53