Dip  0.92.4
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 // 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_DECOMPAPP_INCLUDED
16 #define GAP_DECOMPAPP_INCLUDED
17 
18 // --------------------------------------------------------------------- //
19 #include "DecompApp.h"
20 
21 // --------------------------------------------------------------------- //
22 #include "GAP_Instance.h"
23 #include "GAP_KnapPisinger.h"
24 #include "GAP_DecompParam.h"
25 
26 // --------------------------------------------------------------------- //
37 // --------------------------------------------------------------------- //
38 class GAP_DecompApp : public DecompApp {
39 private:
41  const string m_classTag;
42 
45 
48 
50  vector<GAP_KnapPisinger*> m_knap;
51 
53  double* m_objective;
54 
57  map<string, DecompConstraintSet*> m_models;
58 
59 
60 public:
61  /* @name Inherited (from virtual) methods. */
63  DecompSolverStatus solveRelaxed(const int whichBlock,
64  const double* redCostX,
65  const double target,
66  list<DecompVar*>& vars);
67 
69  void printOriginalColumn(const int index,
70  ostream* os = &cout) const;
71 
72 public:
76  void initializeApp();
77 
79  inline const int getOffsetI(const int i) const {
80  return i * m_instance.getNTasks();
81  }
82  inline const int getIndexIJ(const int i,
83  const int j) const {
84  return (i * m_instance.getNTasks()) + j;
85  }
86 
87  inline pair<int, int> getIndexInv(const int index) const {
88  return make_pair(index / m_instance.getNTasks(),
89  index % m_instance.getNTasks());
90  }
91 
93  int createModels();
95 
96 public:
97  inline const GAP_Instance& getInstance() const {
98  return m_instance;
99  }
100  inline const GAP_DecompParam& getParam() const {
101  return m_appParam;
102  }
103  inline const double* getObjective() const {
104  return m_objective;
105  }
106  inline DecompConstraintSet* getModel(string modelName) const {
107  map<string, DecompConstraintSet*>::const_iterator it;
108  it = m_models.find(modelName);
109 
110  if (it == m_models.end()) {
111  cout << "Error: model with name " << modelName << " not defined."
112  << endl;
113  assert(it != m_models.end());
114  return NULL;
115  }
116 
117  return it->second;
118  }
119 
120 
121 public:
126  DecompApp (utilParam),
127  m_classTag ("GAP-APP"),
128  m_objective (NULL)
129  {
130  m_appParam.getSettings(utilParam);
131 
132  if (m_appParam.LogLevel >= 1) {
134  }
135 
136  initializeApp();
137  }
138 
139  virtual ~GAP_DecompApp() {
141  //UTIL_DELARR(m_objective);
143  };
144 };
145 
146 #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:50
const int getIndexIJ(const int i, const int j) const
Guts of constructor.
Definition: GAP_DecompApp.h:82
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:63
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:97
virtual ~GAP_DecompApp()
Default constructor.
const double * getObjective() const
Guts of constructor.
GAP_DecompParam m_appParam
Application specific parameters.
Definition: GAP_DecompApp.h:47
GAP_Instance m_instance
GAP problem instance data.
Definition: GAP_DecompApp.h:44
void dumpSettings(ostream *os=&cout)
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:79
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:57
int createModels()
TODO comment.
int createModelPartAP(DecompConstraintSet *model)
Guts of constructor.
void getSettings(UtilParameters &utilParam)
double * m_objective
The model objective coefficients (original space).
Definition: GAP_DecompApp.h:53
DecompSolverStatus
Definition: Decomp.h:208
const string m_classTag
Class id tag (for log / debugging).
Definition: GAP_DecompApp.h:41
const GAP_DecompParam & getParam() const
Guts of constructor.
pair< int, int > getIndexInv(const int index) const
Guts of constructor.
Definition: GAP_DecompApp.h:87
void UtilDeleteMapPtr(std::map< S, T * > &mapPtr, typename std::map< S, T * >::iterator first, typename std::map< S, T * >::iterator last)
Definition: UtilMacros.h:651
The main application class.
Definition: DecompApp.h:48
void initializeApp()
Guts of constructor.