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 ,bool deleteStuff=true);
00077 int tightenPrimalBounds(OsiSolverInterface & model,double factor=0.0);
00084 OsiSolverInterface * someFixed(OsiSolverInterface & model,
00085 double fractionToKeep=0.25,
00086 bool fixContinuousAsWell=false,
00087 char * keep=NULL) const;
00092 OsiSolverInterface * cliqueIt(OsiSolverInterface & model,
00093 double cliquesNeeded=0.0) const;
00095 int reducedCostFix(OsiSolverInterface & model);
00097
00098
00099
00114 void setCutoff(double value) ;
00115
00117 double getCutoff() const;
00119 inline OsiSolverInterface * originalModel() const
00120 { return originalModel_;}
00122 inline OsiSolverInterface * startModel() const
00123 { return startModel_;}
00125 inline OsiSolverInterface * modelAtPass(int iPass) const
00126 { if (iPass>=0&&iPass<numberSolvers_) return model_[iPass]; else return NULL;}
00128 inline OsiSolverInterface * modifiedModel(int iPass) const
00129 { if (iPass>=0&&iPass<numberSolvers_) return modifiedModel_[iPass]; else return NULL;}
00131 inline OsiPresolve * presolve(int iPass) const
00132 { if (iPass>=0&&iPass<numberSolvers_) return presolve_[iPass]; else return NULL;}
00135 const int * originalColumns();
00138 const int * originalRows();
00140 inline int numberSOS() const
00141 { return numberSOS_;}
00143 inline const int * typeSOS() const
00144 { return typeSOS_;}
00146 inline const int * startSOS() const
00147 { return startSOS_;}
00149 inline const int * whichSOS() const
00150 { return whichSOS_;}
00152 inline const double * weightSOS() const
00153 { return weightSOS_;}
00155 void passInProhibited(const char * prohibited,int numberColumns);
00157 inline const char * prohibited()
00158 { return prohibited_;}
00160 inline int numberIterationsPre() const
00161 { return numberIterationsPre_;}
00163 inline int numberIterationsPost() const
00164 { return numberIterationsPost_;}
00171 void passInRowTypes(const char * rowTypes,int numberRows);
00178 inline const char * rowTypes()
00179 { return rowType_;}
00181 inline const CglStored & cuts() const
00182 { return cuts_;}
00184 inline const CglStored * cutsPointer() const
00185 { return &cuts_;}
00187 void update(const OsiPresolve * pinfo,const OsiSolverInterface * solver);
00189 inline void setOptions(int value)
00190 { options_=value;}
00192
00194
00195
00196 inline int numberCutGenerators() const
00197 { return numberCutGenerators_;}
00199 inline CglCutGenerator ** cutGenerators() const
00200 { return generator_;}
00202 inline CglCutGenerator * cutGenerator(int i) const
00203 { return generator_[i];}
00206 void addCutGenerator(CglCutGenerator * generator);
00208
00218 void setApplicationData (void * appData);
00219
00221 void * getApplicationData() const;
00223
00224
00225
00228
00229 void passInMessageHandler(CoinMessageHandler * handler);
00231 void newLanguage(CoinMessages::Language language);
00232 inline void setLanguage(CoinMessages::Language language)
00233 {newLanguage(language);}
00235 inline CoinMessageHandler * messageHandler() const
00236 {return handler_;}
00238 inline CoinMessages messages()
00239 {return messages_;}
00241 inline CoinMessages * messagesPointer()
00242 {return &messages_;}
00244
00245
00246
00248
00249
00250 CglPreProcess();
00251
00253 CglPreProcess(const CglPreProcess & rhs);
00254
00256 CglPreProcess & operator=(const CglPreProcess& rhs);
00257
00259 ~CglPreProcess ();
00260
00262 void gutsOfDestructor();
00264 private:
00265
00267
00268
00272 OsiSolverInterface * modified(OsiSolverInterface * model,
00273 bool constraints,
00274 int & numberChanges,
00275 int iBigPass,
00276 int numberPasses);
00278 void createOriginalIndices();
00280 void makeInteger();
00282
00283
00284
00285 private:
00287
00288
00290 OsiSolverInterface * originalModel_;
00292 OsiSolverInterface * startModel_;
00294 int numberSolvers_;
00296 OsiSolverInterface ** model_;
00298 OsiSolverInterface ** modifiedModel_;
00300 OsiPresolve ** presolve_;
00301
00303 CoinMessageHandler * handler_;
00304
00310 bool defaultHandler_;
00311
00313 CoinMessages messages_;
00314
00316 void * appData_;
00318 int * originalColumn_;
00320 int * originalRow_;
00322 int numberCutGenerators_;
00324 CglCutGenerator ** generator_;
00326 int numberSOS_;
00328 int * typeSOS_;
00330 int * startSOS_;
00332 int * whichSOS_;
00334 double * weightSOS_;
00336 int numberProhibited_;
00338 int numberIterationsPre_;
00340 int numberIterationsPost_;
00342 char * prohibited_;
00344 int numberRowType_;
00351 int options_;
00358 char * rowType_;
00360 CglStored cuts_;
00362 };
00364 class CglBK {
00365
00366 public:
00367
00369
00370
00371 void bronKerbosch();
00373 OsiSolverInterface * newSolver(const OsiSolverInterface & model);
00375
00376
00377
00387
00388
00389
00390
00391
00393
00394
00395 CglBK();
00396
00398 CglBK(const OsiSolverInterface & model, const char * rowType,
00399 int numberElements);
00400
00402 CglBK(const CglBK & rhs);
00403
00405 CglBK & operator=(const CglBK& rhs);
00406
00408 ~CglBK ();
00409
00411
00412
00413
00414 private:
00416
00417
00418 int * candidates_;
00420 char * mark_;
00422 int * start_;
00424 int * otherColumn_;
00426 int * originalRow_;
00428 int * dominated_;
00430 CoinPackedMatrix * cliqueMatrix_;
00432 const char * rowType_;
00434 int numberColumns_;
00436 int numberRows_;
00438 int numberPossible_;
00440 int numberCandidates_;
00442 int firstNot_;
00444 int numberIn_;
00446 int left_;
00447 int lastColumn_;
00449 };
00453
00454 typedef struct {
00455 int index, next;
00456 } CglHashLink;
00457 class OsiRowCut;
00458 class CglUniqueRowCuts {
00459 public:
00460
00461 CglUniqueRowCuts(int initialMaxSize=0, int hashMultiplier=4 );
00462 ~CglUniqueRowCuts();
00463 CglUniqueRowCuts(const CglUniqueRowCuts& rhs);
00464 CglUniqueRowCuts& operator=(const CglUniqueRowCuts& rhs);
00465 inline OsiRowCut * cut(int sequence) const
00466 { return rowCut_[sequence];}
00467 inline int numberCuts() const
00468 { return numberCuts_;}
00469 inline int sizeRowCuts() const
00470 { return numberCuts_;}
00471 inline OsiRowCut * rowCutPtr(int sequence)
00472 { return rowCut_[sequence];}
00473 void eraseRowCut(int sequence);
00474
00475 inline void insert(const OsiRowCut & cut)
00476 { insertIfNotDuplicate(cut);}
00477
00478 int insertIfNotDuplicate(const OsiRowCut & cut);
00479
00480 void addCuts(OsiCuts & cs);
00481 private:
00482 OsiRowCut ** rowCut_;
00484 CglHashLink *hash_;
00485 int size_;
00486 int hashMultiplier_;
00487 int numberCuts_;
00488 int lastHash_;
00489 };
00490 #endif