Clp trunk
|
00001 /* $Id$ */ 00002 // Copyright (C) 2002, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef ClpPresolve_H 00007 #define ClpPresolve_H 00008 #include "ClpSimplex.hpp" 00009 00010 class CoinPresolveAction; 00011 #include "CoinPresolveMatrix.hpp" 00015 class ClpPresolve { 00016 public: 00019 00020 ClpPresolve(); 00021 00023 virtual ~ClpPresolve(); 00025 00041 ClpSimplex * presolvedModel(ClpSimplex & si, 00042 double feasibilityTolerance = 0.0, 00043 bool keepIntegers = true, 00044 int numberPasses = 5, 00045 bool dropNames = false, 00046 bool doRowObjective = false); 00047 #ifndef CLP_NO_STD 00048 00051 int presolvedModelToFile(ClpSimplex &si, std::string fileName, 00052 double feasibilityTolerance = 0.0, 00053 bool keepIntegers = true, 00054 int numberPasses = 5, 00055 bool dropNames = false, 00056 bool doRowObjective = false); 00057 #endif 00058 00060 ClpSimplex * model() const; 00062 ClpSimplex * originalModel() const; 00064 void setOriginalModel(ClpSimplex * model); 00065 00067 const int * originalColumns() const; 00069 const int * originalRows() const; 00074 inline void setNonLinearValue(double value) { 00075 nonLinearValue_ = value; 00076 } 00077 inline double nonLinearValue() const { 00078 return nonLinearValue_; 00079 } 00081 inline bool doDual() const { 00082 return (presolveActions_ & 1) == 0; 00083 } 00084 inline void setDoDual(bool doDual) { 00085 if (doDual) presolveActions_ &= ~1; 00086 else presolveActions_ |= 1; 00087 } 00089 inline bool doSingleton() const { 00090 return (presolveActions_ & 2) == 0; 00091 } 00092 inline void setDoSingleton(bool doSingleton) { 00093 if (doSingleton) presolveActions_ &= ~2; 00094 else presolveActions_ |= 2; 00095 } 00097 inline bool doDoubleton() const { 00098 return (presolveActions_ & 4) == 0; 00099 } 00100 inline void setDoDoubleton(bool doDoubleton) { 00101 if (doDoubleton) presolveActions_ &= ~4; 00102 else presolveActions_ |= 4; 00103 } 00105 inline bool doTripleton() const { 00106 return (presolveActions_ & 8) == 0; 00107 } 00108 inline void setDoTripleton(bool doTripleton) { 00109 if (doTripleton) presolveActions_ &= ~8; 00110 else presolveActions_ |= 8; 00111 } 00113 inline bool doTighten() const { 00114 return (presolveActions_ & 16) == 0; 00115 } 00116 inline void setDoTighten(bool doTighten) { 00117 if (doTighten) presolveActions_ &= ~16; 00118 else presolveActions_ |= 16; 00119 } 00121 inline bool doForcing() const { 00122 return (presolveActions_ & 32) == 0; 00123 } 00124 inline void setDoForcing(bool doForcing) { 00125 if (doForcing) presolveActions_ &= ~32; 00126 else presolveActions_ |= 32; 00127 } 00129 inline bool doImpliedFree() const { 00130 return (presolveActions_ & 64) == 0; 00131 } 00132 inline void setDoImpliedFree(bool doImpliedfree) { 00133 if (doImpliedfree) presolveActions_ &= ~64; 00134 else presolveActions_ |= 64; 00135 } 00137 inline bool doDupcol() const { 00138 return (presolveActions_ & 128) == 0; 00139 } 00140 inline void setDoDupcol(bool doDupcol) { 00141 if (doDupcol) presolveActions_ &= ~128; 00142 else presolveActions_ |= 128; 00143 } 00145 inline bool doDuprow() const { 00146 return (presolveActions_ & 256) == 0; 00147 } 00148 inline void setDoDuprow(bool doDuprow) { 00149 if (doDuprow) presolveActions_ &= ~256; 00150 else presolveActions_ |= 256; 00151 } 00153 inline bool doSingletonColumn() const { 00154 return (presolveActions_ & 512) == 0; 00155 } 00156 inline void setDoSingletonColumn(bool doSingleton) { 00157 if (doSingleton) presolveActions_ &= ~512; 00158 else presolveActions_ |= 512; 00159 } 00161 inline bool doGubrow() const { 00162 return (presolveActions_ & 1024) == 0; 00163 } 00164 inline void setDoGubrow(bool doGubrow) { 00165 if (doGubrow) presolveActions_ &= ~1024; 00166 else presolveActions_ |= 1024; 00167 } 00169 inline int presolveActions() const { 00170 return presolveActions_ & 0xffff; 00171 } 00172 inline void setPresolveActions(int action) { 00173 presolveActions_ = (presolveActions_ & 0xffff0000) | (action & 0xffff); 00174 } 00176 inline void setSubstitution(int value) { 00177 substitution_ = value; 00178 } 00180 inline void statistics() { 00181 presolveActions_ |= 0x80000000; 00182 } 00184 int presolveStatus() const; 00185 00194 virtual void postsolve(bool updateStatus = true); 00195 00197 void destroyPresolve(); 00198 00200 private: 00202 ClpSimplex * originalModel_; 00203 00205 ClpSimplex * presolvedModel_; 00211 double nonLinearValue_; 00213 int * originalColumn_; 00215 int * originalRow_; 00217 double * rowObjective_; 00219 const CoinPresolveAction *paction_; 00220 00226 int ncols_; 00227 int nrows_; 00228 CoinBigIndex nelems_; 00230 int numberPasses_; 00232 int substitution_; 00233 #ifndef CLP_NO_STD 00234 00235 std::string saveFile_; 00236 #endif 00237 00241 int presolveActions_; 00242 protected: 00246 virtual const CoinPresolveAction *presolve(CoinPresolveMatrix *prob); 00247 00253 virtual void postsolve(CoinPostsolveMatrix &prob); 00255 virtual ClpSimplex * gutsOfPresolvedModel(ClpSimplex * originalModel, 00256 double feasibilityTolerance, 00257 bool keepIntegers, 00258 int numberPasses, 00259 bool dropNames, 00260 bool doRowObjective); 00261 }; 00262 #endif