My Project
OSColGenApp.h
Go to the documentation of this file.
1 /* $Id: OSColGenApp.h 3038 2009-11-07 11:43:44Z kmartin $ */
13 #ifndef OSCOLGENAPP_H
14 #define OSCOLGENAPP_H
15 
16 // --------------------------------------------------------------------- //
17 #include "OSDataStructures.h"
18 #include "OSDefaultSolver.h"
19 #include "OSrLReader.h"
20 #include "OSOption.h"
21 #include "OSInstance.h"
22 #include "OSoLReader.h"
23 #include "OSCoinSolver.h"
24 #include "OSBearcatSolverXij.h"
25 #include "OSDecompParam.h"
27 
28 #include "OSNode.h"
29 
30 #include <vector>
31 
32 // --------------------------------------------------------------------- //
39 // --------------------------------------------------------------------- //
40 class OSColGenApp {
41 public:
42 
44 
45 
47 
48  //OSBearcatSolverXij *m_osrouteSolver;
49  //OSDecompSolver *m_osrouteSolver;
50 
51  std::ostringstream outStr;
52 
56 
60  std::vector<double> m_zRootLPx_vals;
61 
62 
66  std::vector<int> m_zRootLPx_idx;
67 
68 
69 
74 
78  std::map<int, int> m_rowIdxVarMap;
79 
80 
81  //the OS solver wrapper
83 
84  OsiSolverInterface *m_si;
85 
86 
89 
92 
95 
103 
105  std::string m_message;
106 
108  double m_zUB;
109 
111  double m_zLB;
112 
114  double m_zRootLP;
115 
119  std::map<int, OSNode*> m_nodeMap;
120 
125  std::vector<int> m_zOptIndexes;
126 
132  std::vector<int> m_zOptRootLP;
133 
134 
135  std::map<int, int> inVars;
136 
137 
138 
139 
141  double *m_yA;
142 
144  double *m_yB;
145 
147  double* m_theta;
148 
151 
154 
157 
158 
159  void getOptions( OSOption *osoption);
160 
167  bool branchAndBound();
168 
169  void solve();
170 
171  /***
172  * print the information about the current tree
173  */
174  void printTreeInfo();
175 
176 
178 
188  bool isInteger( const double *thetaVar, const int numThetaVar,
189  const double tol);
190 
191 
192  void printDebugInfo( );
193 
194 
195  void checkNodeConsistency( const int rowIdx, const OSNode *osnode);
196 
210  void getCuts(const double* thetaVar, const int numThetaVar,
211  int &numNewRows, int* &numNonz, int** &colIdx,
212  double** &values, double* &rowLB, double* &rowUB) ;
213 
229  void getColumns(const double* yA, const int numARows,
230  const double* yB, const int numBRows,
231  int &numNewColumns, int* &numNonz, double* &cost,
232  int** &rowIdx, double** &values, double &lowerBound) ;
233 
234 
248  OSNode* createChild(const OSNode *osnode, std::map<int, int> &varConMap,
249  const int rowIdx, const double rowLB, const double rowUB);
250 
251 
252 
266  void createBranchingCut(const int* thetaIdx, const double* theta,
267  const int numThetaVar, std::map<int, int> &varConMap, int &rowIdx);
268 
269 
282  void createBranchingCut(const double* theta, const int numThetaVar,
283  std::map<int, int> &varConMap, int &rowIdx);
284 
285 
286  void resetMaster( );
287 
292  OSColGenApp();
293 
298  OSColGenApp( OSOption *osption);
299 
300 
305  ~OSColGenApp();
306 
307  //
308 };//end class OSColGenApp
309 
310 #endif
311 
OSOption * osoption
Implements a solve method for the Coin solvers.
Definition: OSCoinSolver.h:38
std::ostringstream outStr
Definition: OSColGenApp.h:51
std::vector< int > m_zOptRootLP
m_zOptRootLP is the vector theta indexes corresponding to optimal LP solution at the roor tnode
Definition: OSColGenApp.h:132
void printDebugInfo()
OSOption * m_osoption
Definition: OSColGenApp.h:54
void getColumns(const double *yA, const int numARows, const double *yB, const int numBRows, int &numNewColumns, int *&numNonz, double *&cost, int **&rowIdx, double **&values, double &lowerBound)
RETURN VALUES: int numNewColumns – number of new columns generated int* numNonz – number of nonzeros ...
~OSColGenApp()
Default destructor.
double m_zUB
m_zUB is the upper bound
Definition: OSColGenApp.h:108
OsiSolverInterface * m_si
Definition: OSColGenApp.h:84
OSResult * m_osresult
Definition: OSColGenApp.h:55
OSDecompFactoryInitializer * m_factoryInit
Definition: OSColGenApp.h:43
std::vector< int > m_zOptIndexes
m_zOptIndexes is the vector theta indexes corresponding to the current m_zUB
Definition: OSColGenApp.h:125
double * m_yB
m_yB is the dual for the cuts that get added
Definition: OSColGenApp.h:144
double m_zRootLP
m_zRootLP is the value of the root LP relaxation
Definition: OSColGenApp.h:114
CoinSolver * m_solver
Definition: OSColGenApp.h:82
std::map< int, int > inVars
Definition: OSColGenApp.h:135
OSDecompParam m_osDecompParam
Application specific parameters.
Definition: OSColGenApp.h:88
std::string m_message
m_message is the message to the pauHana routine
Definition: OSColGenApp.h:105
double * m_yA
m_yA is the dual values for the initial restricted constraints
Definition: OSColGenApp.h:141
int m_numNodesGenerated
kount the nodes generated
Definition: OSColGenApp.h:91
void createBranchingCut(const int *thetaIdx, const double *theta, const int numThetaVar, std::map< int, int > &varConMap, int &rowIdx)
INPUT: – sparse version int* thetaIdx – index vector of nonzero theta variables double* theta – the s...
OSDecompSolver * m_osrouteSolver
Definition: OSColGenApp.h:46
int m_maxCols
m_maxCols is the maximum number of columns we can have
Definition: OSColGenApp.h:150
void solveRestrictedMasterRelaxation()
kipp – document
OSInstance * m_osinstanceMaster
Definition: OSColGenApp.h:53
void resetMaster()
void getInitialRestrictedMaster()
std::vector< double > m_zRootLPx_vals
m_zRootLPx_vals holds root node optimal LP solution nonzero values
Definition: OSColGenApp.h:60
std::map< int, int > m_rowIdxVarMap
map the variable generated at a node with a variable
Definition: OSColGenApp.h:78
bool branchAndBound()
the method that invokes and controls branch and bound
void getOptions(OSOption *osoption)
int m_numColumnsOld
when m_numColumnsGenerated - m_numColumnsOld hits masterColumnResetValue we do a reset
Definition: OSColGenApp.h:102
void getCuts(const double *thetaVar, const int numThetaVar, int &numNewRows, int *&numNonz, int **&colIdx, double **&values, double *&rowLB, double *&rowUB)
RETURN VALUES: int numNewRows – number of new rows generated int* numNonz – number of nonzeros in eac...
std::vector< int > m_zRootLPx_idx
m_zRootLPx_idxs holds root node optimal LP solution nonzero indexes
Definition: OSColGenApp.h:66
double m_zLB
m_zLB is the lower bound
Definition: OSColGenApp.h:111
std::map< int, OSNode * > m_nodeMap
nodeMap is the map of nodes in the branch and bound tree
Definition: OSColGenApp.h:119
bool m_calledBranchAndBound
this variable is true if we have called the branchAndBound() method
Definition: OSColGenApp.h:73
int m_numColumnsGenerated
kount the columns generated
Definition: OSColGenApp.h:94
bool isInteger(const double *thetaVar, const int numThetaVar, const double tol)
INPUT: double* thetaVar – the vector of primal master values int numThetaVar – size of master primal ...
OSColGenApp()
Default Constructor.
Definition: OSColGenApp.cpp:51
int m_maxRows
m_maxRows is the maximum number of rows we can have
Definition: OSColGenApp.h:153
void printTreeInfo()
OSNode * createChild(const OSNode *osnode, std::map< int, int > &varConMap, const int rowIdx, const double rowLB, const double rowUB)
INPUT: OSNode* osnode – the parent node for which we create a child std::map<int, int> varConMap – th...
void checkNodeConsistency(const int rowIdx, const OSNode *osnode)
double * m_theta
m_theta is the primal values in the master
Definition: OSColGenApp.h:147
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2263
Definition: OSNode.h:28
The Option Class.
Definition: OSOption.h:3565
The Result Class.
Definition: OSResult.h:2549