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

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.53.1/Cgl/src/CglLandP/CglLandP.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2005, Pierre Bonami and others.  All Rights Reserved.
    00002 // Author:   Pierre Bonami
    00003 //           Tepper School of Business
    00004 //           Carnegie Mellon University, Pittsburgh, PA 15213
    00005 // Date:     07/21/05
    00006 //---------------------------------------------------------------------------
    00007 #ifndef CglLandP_H
    00008 #define CglLandP_H
    00009
    00010 //Several level of Debug
    00011 // 1 - A few simple sanity check
    00012 // 2 - do extra computations on cut quality
    00013 // 3 - Output cut in initial non-basic space (only if logLevel >= 3 )
    00014 // 4 - Double check (compute in two different ways) reduced cost and f+ f-
    00015 //#define LandP_DEBUG 1
    00016
    00017
    00018 #include "CglLandPValidator.hpp"
    00019 #include "CglCutGenerator.hpp"
    00020 #include "CglParam.hpp"
    00021
    00022 #ifdef DO_STAT
    00023 #include "CglLandPStats.hpp"
    00024 #endif
    00025 #include <iostream>
    00026 #include <fstream>
    00027 class CoinWarmStartBasis;
    00032 namespace LAP {
    00033 enum LapMessagesTypes
    00034 {
    00035   BEGIN_ROUND,
    00036   END_ROUND,
    00037   DURING_SEP,
    00038   CUT_REJECTED,
    00039   CUT_FAILED,
    00040   LAP_CUT_FAILED_DO_MIG,
    00041   LAP_MESSAGES_DUMMY_END
    00042 };
    00044 class LapMessages : public CoinMessages
    00045 {
    00046 public:
    00048   LapMessages( );
    00049 };
    00050 class CglLandPSimplex;
    00051 }
    00052
    00053 class CglLandP : public CglCutGenerator
    00054 {
    00055   friend void CglLandPUnitTest(OsiSolverInterface *si, const std::string & mpsDir);
    00056
    00057   friend class LAP::CglLandPSimplex;
    00058
    00059 public:
    00060
    00061   enum SelectionRules {
    00062     mostNegativeRc ,
    00063     bestPivot
    00064   };
    00067   class Parameters : public CglParam {
    00068   public:
    00070     Parameters();
    00072     Parameters(const Parameters &other);
    00074     Parameters & operator=(const Parameters &other);
    00077
    00080     int pivotLimit;
    00083     int pivotLimitInTree;
    00085     int maxCutPerRound;
    00087     int failedPivotLimit;
    00090     int degeneratePivotLimit;
    00094
    00095     double pivotTol;
    00097     double away;
    00099     mutable double timeLimit;
    00101     double singleCutTimeLimit;
    00103
    00106
    00107     bool useTableauRow;
    00109     bool modularize;
    00111     bool strengthen;
    00113     int reducedSpace;
    00115     bool perturb;
    00117     bool scaleCuts;
    00119     SelectionRules pivotSelection;
    00121   };
    00122
    00123
    00125    CglLandP(const CglLandP::Parameters &params = CglLandP::Parameters(),
    00126             const CglValidator &validator = CglValidator());
    00128   ~CglLandP();
    00130    CglLandP(const CglLandP &source);
    00132   CglLandP& operator=(const CglLandP &rhs);
    00134   CglCutGenerator * clone() const;
    00135
    00136 #ifdef DO_STAT
    00137
    00138   void displayStats(){roundsStats_.displaySumUp(*logStream);}
    00139
    00140   void setIdString(const std::string &id){roundsStats_.setIdString(id);}
    00141 #endif
    00142
    00145
    00146   virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
    00147                             const CglTreeInfo info = CglTreeInfo()) const;
    00148
    00150
    00151 virtual bool needsOptimalBasis() const
    00152 {
    00153   return true;
    00154 }
    00155
    00156         CglValidator & validator(){return validator_;}
    00164   void setLogLevel(int level)
    00165   { handler_->setLogLevel(level);
    00166   }
    00167 #ifdef DO_STAT
    00168   void setLogStream(std::ostream & os)
    00169   {
    00170     releaseLogStream();
    00171     logStream = &os;
    00172   }
    00173
    00174 void openLogStream(std::string name){
    00175   releaseLogStream();
    00176   logStream = new std::ofstream(name.c_str(),std::ios::app);
    00177   logAssignCount = new int;
    00178   (*logAssignCount) = 1;
    00179 }
    00180
    00181 inline void releaseLogStream(){
    00182   if(logAssignCount && *logAssignCount){
    00183     (*logAssignCount)--;
    00184     if(*logAssignCount == 0){
    00185       delete logStream;
    00186       delete logAssignCount;
    00187       logAssignCount=NULL;
    00188     }
    00189     else logAssignCount = NULL;
    00190 }
    00191 }
    00192
    00193 void lookupProblem(const std::string &s);
    00194
    00195 #endif
    00196   class NoBasisError : public CoinError
    00197   {
    00198   public:
    00199     NoBasisError(): CoinError("No basis available","LandP",""){}
    00200   };
    00201
    00202   class SimplexInterfaceError : public CoinError
    00203   {
    00204   public:
    00205     SimplexInterfaceError(): CoinError("Invalid conversion to simplex interface", "CglLandP","CglLandP"){}
    00206   };
    00207   Parameters & parameter() {return params_;}
    00208 private:
    00209   Parameters params_;
    00210
    00212   struct CachedData
    00213   {
    00214     CachedData(int nBasics = 0 , int nNonBasics = 0);
    00215     CachedData(const CachedData & source);
    00216
    00217     CachedData& operator=(const CachedData &source);
    00219     void getData(const OsiSolverInterface &si);
    00220     ~CachedData();
    00222     int * basics_;
    00224     int *nonBasics_;
    00226     int nBasics_;
    00228     int nNonBasics_;
    00230     CoinWarmStartBasis * basis_;
    00232     double * colsol_;
    00234     double * slacks_;
    00236     bool * integers_;
    00237   };
    00238   mutable CachedData cached_;
    00240   CoinMessageHandler * handler_;
    00242   CoinMessages messages_;
    00244   CglValidator validator_;
    00245 #ifdef DO_STAT
    00246
    00247   mutable roundsStatistics roundsStats_;
    00249   mutable std::ostream * logStream;
    00251   mutable int * logAssignCount;
    00253   mutable bool used;
    00254 #endif
    00255 };
    00256 void CglLandPUnitTest(OsiSolverInterface *si, const std::string & mpsDir);
    00257
    00258 #endif
    00259