Dip  0.92.4
MAD_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 MAD_DECOMPAPP_INCLUDED
16 #define MAD_DECOMPAPP_INCLUDED
17 
18 #define __MAD_USE_QUALEX__
19 #define __MAD_USE_CLIQUER__
20 
21 // --------------------------------------------------------------------- //
22 #include "DecompApp.h"
23 #include "MAD_MemPool.h"
24 #include "MAD_DecompParam.h"
25 #include "MAD_DecompDebug.h"
26 #include "CoinLpIO.hpp"
27 // --------------------------------------------------------------------- //
28 
29 #ifdef __MAD_USE_CLIQUER__
30 #include "MAD_Cliquer.h"
31 #define cliquer_t MAD_Cliquer
32 #else
33 #define cliquer_t void
34 #endif
35 
36 #ifdef __MAD_USE_QUALEX__
37 #include "MAD_Qualex.h"
38 #define MAD_Qualex MAD_Qualex
39 #else
40 #define MAX_Qualex void
41 #endif
42 
43 // --------------------------------------------------------------------- //
44 typedef enum MAD_HeurSortDir{
47 };
48 
49 // --------------------------------------------------------------------- //
50 typedef struct GreedyPoint GreedyPoint;
51 struct GreedyPoint {
52  double * solution;
54  double solValueRedCost;
55 };
56 
57 
58 // --------------------------------------------------------------------- //
59 
69 // --------------------------------------------------------------------- //
70 class MAD_DecompApp : public DecompApp {
71  private:
73  const string m_classTag;
74 
75  private:
79  int m_beta;
80  int m_kappa;
81 
84 
87 
88  //THINK about data structures! if have cliquer around vs qualex
89  //or just use generic boost? in the case that we have neither?
91 
94 
95 
96  protected:
99 
100  public:
102  enum ModelType {
105  };
106 
107  public:
108  /* @name Inherited (from pure virtual) methods. */
109 
111  //TODO: model object? vs objCoeff?
112  void APPcreateModel(double *& objCoeff,
113  map<int, DecompConstraintSet*> & modelCore,
114  map<int, vector<DecompConstraintSet* > > & modelRelax);
115 
116  public:
117  /* @name Inherited (from virtual) methods. */
118 
120  //TOOD: too messy?
121  DecompStatus APPsolveRelaxed(const int whichModel,
122  const double * redCostX,
123  const double * origCost,
124  const double alpha,
125  const int n_origCols,
126  const bool checkRC,
127  const bool checkDup,
128  bool & isExact,
129  OsiSolverInterface * m_subprobSI,
130  list<DecompVar*> & vars);
131 
133  int APPheuristics(const double * xhat,
134  const double * origCost,
135  vector<DecompSolution*> & xhatIPFeas);
136 
138  int generateInitVars(DecompVarList & initVars);
139 
141  void printOriginalColumn(const int index,
142  ostream * os = &cout) const;
143 
145  void printOriginalSolution(const int n_cols,
146  const double * solution,
147  ostream * os) const;
148 
149  public:
153  inline const int xIndex(const int i,
154  const int b) const{
155  return i * m_beta + b;
156  }
157 
159  inline pair<int,int> xIndexInv(const int index) const{
160  return make_pair(index / m_beta, index % m_beta);
161  }
162 
164  int isOrtho(const int * rowInd1,
165  const int * rowInd2,
166  const int rowLen1,
167  const int rowLen2);
168 
170  void initializeApp(UtilParameters & utilParam);
171 
173  int heuristicGreedy(vector<GreedyPoint> & greedyPoints,
174  const MAD_HeurSortDir sortDir,
175  const double * sortValues,
176  const double * origCost,
177  const double * redCost = NULL);
178  int heuristicGreedy(const MAD_HeurSortDir sortDir,
179  const double * sortValues,
180  const double * origCost,
181  vector<DecompSolution*> & solVec);
182 
183 
184 
185 
186  void printRowMarks(const int * rowInd,
187  const int rowLen) const;
188 
189 
191  inline const int getNOrigRows() const { return m_nOrigRows; }
192  inline const int getBeta() const { return m_beta; }
193  inline const int getKappa() const { return m_kappa; }
194 
195 
196 
197  private:
203  MAD_DecompApp(const MAD_DecompApp &);
205 
206  public:
211  DecompApp(utilParam),
212  m_classTag("MAD-APP"),
213  m_beta(0),
214  m_kappa(0),
215  m_cliquer(0),
216  m_conflictGraph(0),
217  m_auxMemPool(),
218 // m_bestKnownLB(-1.0e20),
219 // m_bestKnownUB( 1.0e20),
220  m_appParam()
221  {
222  initializeApp(utilParam);
223  }
224 
225  virtual ~MAD_DecompApp() {
229  };
230 };
231 
232 #endif
const int getNOrigRows() const
Access method for member data.
int APPheuristics(const double *xhat, const double *origCost, vector< DecompSolution * > &xhatIPFeas)
TODO.
void APPcreateModel(double *&objCoeff, map< int, DecompConstraintSet * > &modelCore, map< int, vector< DecompConstraintSet * > > &modelRelax)
Create the application model(s).
const string m_classTag
Class id tag (for log / debugging).
Definition: MAD_DecompApp.h:73
int generateInitVars(DecompVarList &initVars)
TODO.
DecompStatus
Definition: Decomp.h:184
DecompStatus APPsolveRelaxed(const int whichModel, const double *redCostX, const double *origCost, const double alpha, const int n_origCols, const bool checkRC, const bool checkDup, bool &isExact, OsiSolverInterface *m_subprobSI, list< DecompVar * > &vars)
Solve the relaxed problem.
Class to read and write Lp files.
Definition: CoinLpIO.hpp:105
const int xIndex(const int i, const int b) const
Global index for column x[i,b].
MAD_MemPool m_auxMemPool
Auxiliary memory storage.
Definition: MAD_DecompApp.h:93
int isOrtho(const int *rowInd1, const int *rowInd2, const int rowLen1, const int rowLen2)
Are the two vectors orthogonal?
void printRowMarks(const int *rowInd, const int rowLen) const
Global index for column x[i,b].
const int getBeta() const
Global index for column x[i,b].
MAD_DecompParam m_appParam
Application specific parameters.
Definition: MAD_DecompApp.h:98
MAD_DecompApp(UtilParameters &utilParam)
Default constructor.
MAD_HeurSortDir
Definition: MAD_DecompApp.h:44
#define cliquer_t
Definition: MAD_DecompApp.h:31
MAD_DecompApp(const MAD_DecompApp &)
virtual void initializeApp()
Initialize applications.
Abstract Base Class for describing an interface to a solver.
pair< int, int > xIndexInv(const int index) const
Return the indices (i,b) given the index.
CoinLpIO m_instance
MAD problem instance data.
Definition: MAD_DecompApp.h:77
ModelType
Model types.
Relaxation is a Maximum Weighted Clique Problem.
#define UTIL_DELPTR(x)
Definition: UtilMacros.h:28
double solValueRedCost
Definition: MAD_DecompApp.h:54
MAD_DecompApp & operator=(const MAD_DecompApp &)
double * solution
Definition: MAD_DecompApp.h:52
void printOriginalColumn(const int index, ostream *os=&cout) const
Print an original column (format for this app).
void graph_free(graph_t *g)
virtual ~MAD_DecompApp()
Default constructor.
cliquer_t * m_cliquer
Storage for cliquer graph.
Definition: MAD_DecompApp.h:83
int heuristicGreedy(vector< GreedyPoint > &greedyPoints, const MAD_HeurSortDir sortDir, const double *sortValues, const double *origCost, const double *redCost=NULL)
TODO.
std::list< DecompVar * > DecompVarList
Definition: Decomp.h:91
MAD_Qualex * m_qualex
Storage for MAD_Qualex interface.
Definition: MAD_DecompApp.h:86
const int getKappa() const
Global index for column x[i,b].
void printOriginalSolution(const int n_cols, const double *solution, ostream *os) const
Print the full original column (format for this app).
The main application class.
Definition: DecompApp.h:48
graph_t * m_conflictGraph
Definition: MAD_DecompApp.h:90
double solValueOrigCost
Definition: MAD_DecompApp.h:53