Dip  0.92.4
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-2007, Lehigh University, Matthew Galati, and Ted Ralphs//
10 // All Rights Reserved. //
11 //===========================================================================//
12 
13 
14 #ifndef DECOMP_APP_INCLUDED
15 #define DECOMP_APP_INCLUDED
16 
17 /*-----------------------------------------------------------------------*/
18 #include "UtilParameters.h"
19 #include "DecompParam.h"
20 #include "DecompModel.h"
21 #include "DecompSolution.h"
22 #include "DecompConstraintSet.h"
23 
24 /*-----------------------------------------------------------------------*/
41 /*-----------------------------------------------------------------------*/
42 class DecompApp {
43 
44 private:
48  DecompApp(const DecompApp&);
49  DecompApp& operator=(const DecompApp&);
50 
51 private:
55  static const char* m_classTag;
56 
57 protected:
61  ostream* m_osLog;
62 
63 public:
68 
73  map<int, DecompConstraintSet*> m_modelCore;
74  map<int, DecompConstraintSet*> m_modelRelax;
75 
76 public:
77  //set log file
81  void startupLog();
82 
83  //base layer needs to do some kind of check to make sure this actually
84  //got done - but also nice to have user version... so base createModel
85  //and user uesrCreateModel() which is pure?, in base userCreateModel
86  //gets called and checked that it returns good information
87  int createModel();
88  //interface method idea of Gardner - so it is very clear
89  //what they can and cannot override and what they must
90  virtual void APPcreateModel(double *& objCoeff,
91  map<int, DecompConstraintSet*> & modelCore,
92  map<int, DecompConstraintSet*> & modelRelax) = 0;
93 
94  //?
95  virtual bool APPisUserFeasible(const double* x,
96  const int n_cols,
97  const double tolZero) {
98  return true;
99  };
100 
101  virtual int APPheuristics(const double* xhat,
102  vector<DecompSolution*> & xhatIPFeas) {
103  return 1;
104  }
105 
106  virtual int generateInitVars(DecompVarList& initVars,
107  int whichModel);
108 
109  //APPgenerateCuts?
110  virtual int generateCuts(const double* x,
111  const DecompConstraintSet& modelCore,
112  const DecompConstraintSet& modelRelax,
113  DecompCutList& newCuts);
114 
115  virtual decompStat APPsolveRelaxed(const int whichModel,
116  const double* redCostX,
117  const double* origCost,
118  const double alpha,
119  const int n_origCols,
120  const bool checkRC,
121  const bool checkDup,
122  OsiSolverInterface* m_subprobSI,
123  list<DecompVar*> & vars) {
124  return STAT_UNKNOWN;
125  }
126 
127 
128  virtual void printOriginalColumn(const int index,
129  ostream* os = &cout) const;
130 
131  virtual void printOriginalSolution(const int n_cols,
132  const double* solution,
133  ostream* os = &cout) const;
134 
135  //Cut(this){
136 public:
137  DecompApp(UtilParameters& utilParam) :
138  m_osLog(&cout),
139  m_param(),
140  m_model(),
141  m_modelCore(),
142  m_modelRelax() {
143  m_param.getSettings(utilParam);
144  startupLog();
145  };
146  virtual ~DecompApp() {
147  map<int, DecompConstraintSet*>::iterator it;
148 
149  for (it = m_modelCore.begin(); it != m_modelCore.end(); it++) {
150  UTIL_DELPTR(it->second);
151  }
152 
153  for (it = m_modelRelax.begin(); it != m_modelRelax.end(); it++) {
154  UTIL_DELPTR(it->second);
155  }
156  };
157 };
158 
159 #endif
std::list< DecompCut * > DecompCutList
Definition: Decomp.h:93
map< int, DecompConstraintSet * > m_modelCore
Definition: DecompApp.h:73
std::map< int, DecompModel > m_modelRelax
Model data: the relaxed model(s) (A&#39;)
Definition: DecompApp.h:95
virtual void APPcreateModel(double *&objCoeff, map< int, DecompConstraintSet * > &modelCore, map< int, DecompConstraintSet * > &modelRelax)=0
virtual void printOriginalColumn(const int index, std::ostream *os=&std::cout) const
Initialize the dual vector for PhaseII of PC.
static const char * m_classTag
Definition: DecompApp.h:55
DecompApp(UtilParameters &utilParam)
Constructor for base DecompApp class.
Definition: DecompApp.h:442
virtual bool APPisUserFeasible(const double *x, const int n_cols, const double tolZero)
Definition: DecompApp.h:95
virtual decompStat APPsolveRelaxed(const int whichModel, const double *redCostX, const double *origCost, const double alpha, const int n_origCols, const bool checkRC, const bool checkDup, OsiSolverInterface *m_subprobSI, list< DecompVar * > &vars)
Definition: DecompApp.h:115
virtual int APPheuristics(const double *xhat, vector< DecompSolution * > &xhatIPFeas)
Definition: DecompApp.h:101
DecompModel m_modelCore
Model data: the core model (A&#39;&#39;)
Definition: DecompApp.h:90
virtual int generateCuts(const double *x, DecompCutList &newCuts)
Initialize the dual vector for PhaseII of PC.
DecompApp & operator=(const DecompApp &)
virtual ~DecompApp()
Definition: DecompApp.h:146
decompStat
std::ostream * m_osLog
Log file.
Definition: DecompApp.h:60
void getSettings(UtilParameters &param)
Definition: DecompParam.h:453
ostream * m_osLog
Definition: DecompApp.h:61
DecompModel m_model
Definition: DecompApp.h:72
void startupLog()
Print startup message to log.
map< int, DecompConstraintSet * > m_modelRelax
Definition: DecompApp.h:74
Abstract Base Class for describing an interface to a solver.
#define UTIL_DELPTR(x)
Definition: UtilMacros.h:28
virtual int generateInitVars(DecompVarList &initVars)
Initialize the dual vector for PhaseII of PC.
DecompParam m_param
Parameters.
Definition: DecompApp.h:79
virtual void printOriginalSolution(const int n_cols, const std::vector< std::string > &colNames, const double *solution, std::ostream *os=&std::cout) const
Initialize the dual vector for PhaseII of PC.
int createModel()
Preprocess (standard ): on the TODO list.
std::list< DecompVar * > DecompVarList
Definition: Decomp.h:91
The main application class.
Definition: DecompApp.h:48