- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/svn-release/Alps-1.5.2/Cgl/src/CglPreProcess/CglPreProcess.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2005, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003 // This code is licensed under the terms of the Eclipse Public License (EPL).
    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_;
    00353   int options_;
    00360   char * rowType_;
    00362   CglStored cuts_;
    00364 };
    00366 class CglBK  {
    00367
    00368 public:
    00369
    00371
    00372
    00373   void bronKerbosch();
    00375   OsiSolverInterface * newSolver(const OsiSolverInterface & model);
    00377
    00378   //---------------------------------------------------------------------------
    00379
    00389
    00390
    00391   //---------------------------------------------------------------------------
    00392
    00393
    00395
    00396
    00397   CglBK();
    00398
    00400   CglBK(const OsiSolverInterface & model, const char * rowType,
    00401         int numberElements);
    00402
    00404   CglBK(const CglBK & rhs);
    00405
    00407   CglBK & operator=(const CglBK& rhs);
    00408
    00410   ~CglBK ();
    00411
    00413
    00414 //---------------------------------------------------------------------------
    00415
    00416 private:
    00418
    00419
    00420   int * candidates_;
    00422   char * mark_;
    00424   int * start_;
    00426   int * otherColumn_;
    00428   int * originalRow_;
    00430   int * dominated_;
    00432   CoinPackedMatrix * cliqueMatrix_;
    00434   const char * rowType_;
    00436   int numberColumns_;
    00438   int numberRows_;
    00440   int numberPossible_;
    00442   int numberCandidates_;
    00444   int firstNot_;
    00446   int numberIn_;
    00448   int left_;
    00449   int lastColumn_;
    00451 };
    00455 // for hashing
    00456 typedef struct {
    00457   int index, next;
    00458 } CglHashLink;
    00459 class OsiRowCut;
    00460 class CglUniqueRowCuts {
    00461 public:
    00462
    00463   CglUniqueRowCuts(int initialMaxSize=0, int hashMultiplier=4 );
    00464   ~CglUniqueRowCuts();
    00465   CglUniqueRowCuts(const CglUniqueRowCuts& rhs);
    00466   CglUniqueRowCuts& operator=(const CglUniqueRowCuts& rhs);
    00467   inline OsiRowCut * cut(int sequence) const
    00468   { return rowCut_[sequence];}
    00469   inline int numberCuts() const
    00470   { return numberCuts_;}
    00471   inline int sizeRowCuts() const
    00472   { return numberCuts_;}
    00473   inline OsiRowCut * rowCutPtr(int sequence)
    00474   { return rowCut_[sequence];}
    00475   void eraseRowCut(int sequence);
    00476   // insert cut
    00477   inline void insert(const OsiRowCut & cut)
    00478   { insertIfNotDuplicate(cut);}
    00479   // Return 0 if added, 1 if not
    00480   int insertIfNotDuplicate(const OsiRowCut & cut);
    00481   // Add in cuts as normal cuts (and delete)
    00482   void addCuts(OsiCuts & cs);
    00483 private:
    00484   OsiRowCut ** rowCut_;
    00486   CglHashLink *hash_;
    00487   int size_;
    00488   int hashMultiplier_;
    00489   int numberCuts_;
    00490   int lastHash_;
    00491 };
    00492 #endif