Dip-All  0.91.0
GAP_DecompApp.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_DECOMPAPP_INCLUDED
14 #define GAP_DECOMPAPP_INCLUDED
15 
16 // --------------------------------------------------------------------- //
17 #include "DecompApp.h"
18 
19 // --------------------------------------------------------------------- //
20 #include "GAP_Instance.h"
21 #include "GAP_KnapPisinger.h"
22 #include "GAP_DecompParam.h"
23 
24 // --------------------------------------------------------------------- //
35 // --------------------------------------------------------------------- //
36 class GAP_DecompApp : public DecompApp {
37 private:
39  const string m_classTag;
40 
43 
46 
48  vector<GAP_KnapPisinger*> m_knap;
49 
51  double* m_objective;
52 
55  map<string, DecompConstraintSet*> m_models;
56 
57 
58 public:
59  /* @name Inherited (from virtual) methods. */
61  DecompSolverStatus solveRelaxed(const int whichBlock,
62  const double* redCostX,
63  const double target,
64  list<DecompVar*>& vars);
65 
67  void printOriginalColumn(const int index,
68  ostream* os = &cout) const;
69 
70 public:
74  void initializeApp(UtilParameters& utilParam);
75 
77  inline const int getOffsetI(const int i) const {
78  return i * m_instance.getNTasks();
79  }
80  inline const int getIndexIJ(const int i,
81  const int j) const {
82  return (i * m_instance.getNTasks()) + j;
83  }
84 
85  inline pair<int, int> getIndexInv(const int index) const {
86  return make_pair(index / m_instance.getNTasks(),
87  index % m_instance.getNTasks());
88  }
89 
91  int createModels();
93 
94 public:
95  inline const GAP_Instance& getInstance() const {
96  return m_instance;
97  }
98  inline const GAP_DecompParam& getParam() const {
99  return m_appParam;
100  }
101  inline const double* getObjective() const {
102  return m_objective;
103  }
104  inline DecompConstraintSet* getModel(string modelName) const {
105  map<string, DecompConstraintSet*>::const_iterator it;
106  it = m_models.find(modelName);
107 
108  if (it == m_models.end()) {
109  cout << "Error: model with name " << modelName << " not defined."
110  << endl;
111  assert(it != m_models.end());
112  return NULL;
113  }
114 
115  return it->second;
116  }
117 
118 
119 public:
124  DecompApp (),
125  m_classTag ("GAP-APP"),
126  m_objective (NULL) {
127  initializeApp(utilParam);
128  }
129 
130  virtual ~GAP_DecompApp() {
132  //UTIL_DELARR(m_objective);
134  };
135 };
136 
137 #endif
void UtilDeleteVectorPtr(vector< T * > &vectorPtr, typename vector< T * >::iterator first, typename vector< T * >::iterator last)
Definition: UtilMacros.h:288
vector< GAP_KnapPisinger * > m_knap
GAP_Knapsack object for each knapsack row.
Definition: GAP_DecompApp.h:48
const int getIndexIJ(const int i, const int j) const
Guts of constructor.
Definition: GAP_DecompApp.h:80
DecompSolverStatus solveRelaxed(const int whichBlock, const double *redCostX, const double target, list< DecompVar * > &vars)
Solve the relaxed problem.
const int getNTasks() const
Definition: GAP_Instance.h:61
void printOriginalColumn(const int index, ostream *os=&cout) const
Print an original column (format for this app).
const GAP_Instance & getInstance() const
Guts of constructor.
Definition: GAP_DecompApp.h:95
virtual ~GAP_DecompApp()
Default constructor.
const double * getObjective() const
Guts of constructor.
GAP_DecompParam m_appParam
Application specific parameters.
Definition: GAP_DecompApp.h:45
void initializeApp(UtilParameters &utilParam)
Guts of constructor.
GAP_Instance m_instance
GAP problem instance data.
Definition: GAP_DecompApp.h:42
GAP_DecompApp(UtilParameters &utilParam)
Default constructor.
DecompConstraintSet * getModel(string modelName) const
Guts of constructor.
const int getOffsetI(const int i) const
TODO comment.
Definition: GAP_DecompApp.h:77
map< string, DecompConstraintSet * > m_models
The various model constraint systems used for different algorithms, keyed by a unique string (model n...
Definition: GAP_DecompApp.h:55
int createModels()
TODO comment.
int createModelPartAP(DecompConstraintSet *model)
Guts of constructor.
double * m_objective
The model objective coefficients (original space).
Definition: GAP_DecompApp.h:51
DecompSolverStatus
Definition: Decomp.h:170
const string m_classTag
Class id tag (for log / debugging).
Definition: GAP_DecompApp.h:39
const GAP_DecompParam & getParam() const
Guts of constructor.
Definition: GAP_DecompApp.h:98
pair< int, int > getIndexInv(const int index) const
Guts of constructor.
Definition: GAP_DecompApp.h:85
void UtilDeleteMapPtr(std::map< S, T * > &mapPtr, typename std::map< S, T * >::iterator first, typename std::map< S, T * >::iterator last)
Definition: UtilMacros.h:652
The main application class.
Definition: DecompApp.h:50