00001 /* $Id: OSDipInterface.h 3038 2009-11-07 11:43:44Z Gassmann $ */ 00016 #ifndef OSDIPINTERFACE_H 00017 #define OSDIPINTERFACE_H 00018 00019 //===========================================================================// 00020 #include "UtilMacros.h" 00021 #include "OSInstance.h" 00022 #include "OSCoinSolver.h" 00023 #include "OSConfig.h" 00024 #include "OSResult.h" 00025 #include "OSOption.h" 00026 #include "OSiLReader.h" 00027 #include "OSiLWriter.h" 00028 #include "OSoLReader.h" 00029 #include "OSoLWriter.h" 00030 #include "OSrLReader.h" 00031 #include "OSrLWriter.h" 00032 #include "OSInstance.h" 00033 #include "OSFileUtil.h" 00034 #include "CoinError.hpp" 00035 #include "OSDefaultSolver.h" 00036 #include "OSWSUtil.h" 00037 #include "OSErrorClass.h" 00038 #include "OSMathUtil.h" 00039 #include "CoinHelperFunctions.hpp" 00040 00041 00042 00043 #include <set> 00044 #include <map> 00045 #include <vector> 00046 00047 //===========================================================================// 00056 //===========================================================================// 00057 class OS_DipInterface { 00058 00059 00060 public: 00061 00063 bool m_isProvenOptimal; 00064 double m_bestKnownLB; 00065 double m_bestKnownUB; 00066 00067 00068 00069 OSInstance *m_osinstance; 00070 OSOption *m_osoption; 00071 OSiLReader *m_osilreader; 00072 OSoLReader *m_osolreader; 00073 char* m_integerVars; 00074 CoinPackedMatrix *m_coinpm; 00075 CoinPackedVector *m_row ; 00076 00077 00079 void readOSiL(std::string & filename); 00080 00081 void readOSoL(std::string & filename); 00082 00083 CoinPackedVector *getRow( int i); 00084 00085 //return a CoinPackedMatrix 00086 CoinPackedMatrix *getCoinPackedMatrix( ); 00087 00093 const char* getIntegerColumns(); 00094 00095 //get the objective function constant 00096 double getObjectiveOffset() ; 00097 00098 00099 //get the set of variable indexes for each block in the model 00100 std::vector<std::set<int> > getBlockVarIndexes(); 00101 std::vector<std::set<int> > m_blockVariableIndexes; 00102 bool m_blockVariableIndexesProcessed; 00103 00104 //get the set of core constraint indexes 00105 std::set<int> getCoreConstraintIndexes(); 00106 std::set<int> m_coreConstraintIndexes; 00107 bool m_coreConstraintIndexesProcessed; 00108 00109 //get a map of constraint indexes for each block in the model 00110 //the key is the index of the constraint in the original problem 00111 //the key points to the index number in the block 00112 std::vector<std::map<int, int> > getBlockConstraintIndexes(); 00113 std::vector<std::map<int, int> > m_blockConstraintIndexes; 00114 bool m_blockConstraintIndexesProcessed; 00115 00116 //get and osinstance that corresponds to each block in the model 00117 std::vector<OSInstance* > getBlockOSInstances(); 00118 std::vector<OSInstance* > m_blockOSInstances; 00119 bool m_blockOSInstancesProcessed; 00120 00121 00122 //get factory solver for each block in the model 00123 std::vector<std::string > getBlockFactories(); 00124 std::vector<std::string > m_blockFactories; 00125 bool m_blockFactoriesProcessed; 00126 00127 00128 //get the objective function coefficients 00129 double *getObjectiveFunctionCoeff(); 00130 00131 00132 inline const double getBestKnownLB() const {return m_bestKnownLB;} //kipp can we get rid of this 00133 inline const double getBestKnownUB() const {return m_bestKnownUB;} // kipp can we get rid of this 00134 00135 00136 //some OS wrapper methods 00137 00144 inline const std::string* getObjectiveMaxOrMins() const {return m_osinstance->getObjectiveMaxOrMins();} 00145 00146 00153 inline const double* getObjectiveConstants() const {return m_osinstance->getObjectiveConstants();} 00154 00161 inline const double* getObjectiveWeights() const {return m_osinstance->getObjectiveWeights();} 00162 00167 inline const int getNumberOfIntegerVariables() const {return m_osinstance->getNumberOfIntegerVariables();} 00168 00173 inline const int getNumberOfBinaryVariables() const {return m_osinstance->getNumberOfBinaryVariables();} 00174 00175 00181 inline const int getVariableNumber() const {return m_osinstance->getVariableNumber();} 00182 00188 inline const int getConstraintNumber() const {return m_osinstance->getConstraintNumber();} 00189 00195 inline const double* getColLower() const {return m_osinstance->getVariableLowerBounds();} 00196 00197 00203 inline const double* getColUpper() const {return m_osinstance->getVariableUpperBounds();} 00204 00205 00211 inline const std::string* getVariableNames() const {return m_osinstance->getVariableNames();} 00212 00213 00219 inline const double* getRowLower() const {return m_osinstance->getConstraintLowerBounds();} 00220 00221 00227 inline const double* getRowUpper() const {return m_osinstance->getConstraintUpperBounds();} 00228 00229 00235 inline const std::string* getConstraintNames() const {return m_osinstance->getConstraintNames();} 00236 00237 00238 std::map<int, std::vector< int> > generateInitialMaster(); 00239 00240 //end wrapper methods 00241 00243 OS_DipInterface(); 00244 00246 ~OS_DipInterface(); 00247 }; 00248 00249 #endif