00001
00002
00003
00004
00005 #ifndef CglPreProcess_H
00006 #define CglPreProcess_H
00007
00008 #include <string>
00009 #include <vector>
00010
00011 #include "CoinMessageHandler.hpp"
00012 #include "OsiSolverInterface.hpp"
00013 #include "CglStored.hpp"
00014 #include "OsiPresolve.hpp"
00015 #include "CglCutGenerator.hpp"
00016
00017
00018
00036 class CglPreProcess {
00037
00038 public:
00039
00041
00042
00051 OsiSolverInterface * preProcess(OsiSolverInterface & model,
00052 bool makeEquality=false, int numberPasses=5);
00064 OsiSolverInterface * preProcessNonDefault(OsiSolverInterface & model,
00065 int makeEquality=0, int numberPasses=5,
00066 int tuning=0);
00068 void postProcess(OsiSolverInterface &model
00069 #ifdef KEEP_POSTPROCESS
00070 ,bool deleteStuff=true
00071 #endif
00072 );
00080 int tightenPrimalBounds(OsiSolverInterface & model,double factor=0.0);
00087 OsiSolverInterface * someFixed(OsiSolverInterface & model,
00088 double fractionToKeep=0.25,
00089 bool fixContinuousAsWell=false,
00090 char * keep=NULL) const;
00095 OsiSolverInterface * cliqueIt(OsiSolverInterface & model,
00096 double cliquesNeeded=0.0) const;
00098 int reducedCostFix(OsiSolverInterface & model);
00100
00101
00102
00117 void setCutoff(double value) ;
00118
00120 double getCutoff() const;
00122 inline OsiSolverInterface * originalModel() const
00123 { return originalModel_;}
00125 inline OsiSolverInterface * startModel() const
00126 { return startModel_;}
00128 inline OsiSolverInterface * modelAtPass(int iPass) const
00129 { if (iPass>=0&&iPass<numberSolvers_) return model_[iPass]; else return NULL;}
00131 inline OsiSolverInterface * modifiedModel(int iPass) const
00132 { if (iPass>=0&&iPass<numberSolvers_) return modifiedModel_[iPass]; else return NULL;}
00134 inline OsiPresolve * presolve(int iPass) const
00135 { if (iPass>=0&&iPass<numberSolvers_) return presolve_[iPass]; else return NULL;}
00138 const int * originalColumns() const;
00141 const int * originalRows() const;
00143 inline int numberSOS() const
00144 { return numberSOS_;}
00146 inline const int * typeSOS() const
00147 { return typeSOS_;}
00149 inline const int * startSOS() const
00150 { return startSOS_;}
00152 inline const int * whichSOS() const
00153 { return whichSOS_;}
00155 inline const double * weightSOS() const
00156 { return weightSOS_;}
00158 void passInProhibited(const char * prohibited,int numberColumns);
00160 inline const char * prohibited()
00161 { return prohibited_;}
00163 inline int numberIterationsPre() const
00164 { return numberIterationsPre_;}
00166 inline int numberIterationsPost() const
00167 { return numberIterationsPost_;}
00174 void passInRowTypes(const char * rowTypes,int numberRows);
00181 inline const char * rowTypes()
00182 { return rowType_;}
00184 inline const CglStored & cuts() const
00185 { return cuts_;}
00187 inline const CglStored * cutsPointer() const
00188 { return &cuts_;}
00190 void update(const OsiPresolve * pinfo,const OsiSolverInterface * solver);
00192 inline void setOptions(int value)
00193 { options_=value;}
00195
00197
00198
00199 inline int numberCutGenerators() const
00200 { return numberCutGenerators_;}
00202 inline CglCutGenerator ** cutGenerators() const
00203 { return generator_;}
00205 inline CglCutGenerator * cutGenerator(int i) const
00206 { return generator_[i];}
00209 void addCutGenerator(CglCutGenerator * generator);
00211
00221 void setApplicationData (void * appData);
00222
00224 void * getApplicationData() const;
00226
00227
00228
00231
00232 void passInMessageHandler(CoinMessageHandler * handler);
00234 void newLanguage(CoinMessages::Language language);
00235 inline void setLanguage(CoinMessages::Language language)
00236 {newLanguage(language);}
00238 inline CoinMessageHandler * messageHandler() const
00239 {return handler_;}
00241 inline CoinMessages messages()
00242 {return messages_;}
00244 inline CoinMessages * messagesPointer()
00245 {return &messages_;}
00247
00248
00249
00251
00252
00253 CglPreProcess();
00254
00256 CglPreProcess(const CglPreProcess & rhs);
00257
00259 CglPreProcess & operator=(const CglPreProcess& rhs);
00260
00262 ~CglPreProcess ();
00263
00265 void gutsOfDestructor();
00267 private:
00268
00270
00271
00275 OsiSolverInterface * modified(OsiSolverInterface * model,
00276 bool constraints,
00277 int & numberChanges,
00278 int iBigPass,
00279 int numberPasses);
00281 void createOriginalIndices() const;
00283 void makeInteger();
00285
00286
00287
00288 private:
00290
00291
00293 OsiSolverInterface * originalModel_;
00295 OsiSolverInterface * startModel_;
00297 int numberSolvers_;
00299 OsiSolverInterface ** model_;
00301 OsiSolverInterface ** modifiedModel_;
00303 OsiPresolve ** presolve_;
00304
00306 CoinMessageHandler * handler_;
00307
00313 bool defaultHandler_;
00314
00316 CoinMessages messages_;
00317
00319 void * appData_;
00321 mutable int * originalColumn_;
00323 mutable int * originalRow_;
00325 int numberCutGenerators_;
00327 CglCutGenerator ** generator_;
00329 int numberSOS_;
00331 int * typeSOS_;
00333 int * startSOS_;
00335 int * whichSOS_;
00337 double * weightSOS_;
00339 int numberProhibited_;
00341 int numberIterationsPre_;
00343 int numberIterationsPost_;
00345 char * prohibited_;
00347 int numberRowType_;
00354 int options_;
00361 char * rowType_;
00363 CglStored cuts_;
00365 };
00367 class CglBK {
00368
00369 public:
00370
00372
00373
00374 void bronKerbosch();
00376 OsiSolverInterface * newSolver(const OsiSolverInterface & model);
00378
00379
00380
00390
00391
00392
00393
00394
00396
00397
00398 CglBK();
00399
00401 CglBK(const OsiSolverInterface & model, const char * rowType,
00402 int numberElements);
00403
00405 CglBK(const CglBK & rhs);
00406
00408 CglBK & operator=(const CglBK& rhs);
00409
00411 ~CglBK ();
00412
00414
00415
00416
00417 private:
00419
00420
00421 int * candidates_;
00423 char * mark_;
00425 int * start_;
00427 int * otherColumn_;
00429 int * originalRow_;
00431 int * dominated_;
00433 CoinPackedMatrix * cliqueMatrix_;
00435 const char * rowType_;
00437 int numberColumns_;
00439 int numberRows_;
00441 int numberPossible_;
00443 int numberCandidates_;
00445 int firstNot_;
00447 int numberIn_;
00449 int left_;
00450 int lastColumn_;
00452 };
00453
00454 #endif