00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef IpCbcOACutGenerator2_HPP
00012 #define IpCbcOACutGenerator2_HPP
00013 #include "CglCutGenerator.hpp"
00014 #include "IpoptInterface.hpp"
00015 #include "OaMessages.hpp"
00016 #include "CbcModel.hpp"
00017
00018 #include "CbcStrategy.hpp"
00019
00020 #include "CoinTime.hpp"
00021
00022
00023 class IpCbcOACutGenerator2 : public CglCutGenerator
00024 {
00025 public:
00026 typedef enum subSolver {Clp, Cbc, Cplex, Other};
00028 IpCbcOACutGenerator2();
00030 IpCbcOACutGenerator2(IpoptInterface * nlp = NULL,
00031 OsiSolverInterface * si = NULL,
00032 CbcStrategy * strategy = NULL,
00033 double cbcCutoffIncrement_=1e-07,
00034 double cbcIntegerTolerance = 1e-05,
00035 bool solveAuxiliaryProblem = 1,
00036 bool leaveSiUnchanged = 0
00037 );
00038
00040 IpCbcOACutGenerator2(const IpCbcOACutGenerator2 ©)
00041 :nlp_(copy.nlp_),
00042 si_(copy.si_),
00043 cbcCutoffIncrement_(copy.cbcCutoffIncrement_),
00044 cbcIntegerTolerance_(copy.cbcIntegerTolerance_),
00045 localSearchNodeLimit_(copy.localSearchNodeLimit_),
00046 maxLocalSearchPerNode_(copy.maxLocalSearchPerNode_),
00047 maxLocalSearch_(copy.maxLocalSearch_),
00048 maxLocalSearchTime_(copy.maxLocalSearchTime_),
00049 nLocalSearch_(copy.nLocalSearch_),
00050 solveAuxiliaryProblem_(copy.solveAuxiliaryProblem_),
00051 handler_(NULL), messages_(copy.messages_),
00052 subMilpLogLevel_(copy.subMilpLogLevel_),
00053 leaveSiUnchanged_(copy.leaveSiUnchanged_),
00054 strategy_(NULL),
00055 timeBegin_(0.),
00056 logFrequency_(copy.logFrequency_)
00057 {
00058 handler_ = copy.handler_->clone();
00059 if(copy.strategy_)
00060 strategy_ = copy.strategy_->clone();
00061 timeBegin_ = CoinCpuTime();
00062 }
00064 ~IpCbcOACutGenerator2();
00065
00067 void assignNlpInterface(IpoptInterface * nlp);
00068
00070 void assignLpInterface(OsiSolverInterface * si);
00071
00072 void setStrategy(const CbcStrategy & strategy)
00073 {
00074 if(strategy_)
00075 delete strategy_;
00076 strategy_ = strategy.clone();
00077 }
00079 virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
00080 const CglTreeInfo info = CglTreeInfo()) const;
00081
00082 virtual CglCutGenerator * clone() const
00083 {
00084 return new IpCbcOACutGenerator2(*this);
00085 }
00086
00087 inline int getNSolve()
00088 {
00089 return nSolve_;
00090 }
00092 void setcbcCutoffIncrement (double value)
00093 {
00094 cbcCutoffIncrement_ = value;
00095 }
00097 void setcbcIntegerTolerance (double value)
00098 {
00099 cbcIntegerTolerance_ = value;
00100 }
00102 void setLocalSearchNodeLimit(int value)
00103 {
00104 localSearchNodeLimit_ = value;
00105 if(si_)
00106 setTheNodeLimit();
00107 }
00109 void setMaxLocalSearchPerNode(int value)
00110 {
00111 maxLocalSearchPerNode_ = value;
00112 }
00114 void setMaxLocalSearch(int value)
00115 {
00116 maxLocalSearch_ = value;
00117 }
00118
00119 void setMaxLocalSearchTime(double time)
00120 {
00121 maxLocalSearchTime_ = time;
00122 }
00124 void setLogLevel(int value)
00125 {
00126 handler_->setLogLevel(value);
00127 }
00128
00129
00130 CoinMessageHandler * messageHandler(){
00131 return handler_;
00132 }
00134 void setLogFrequency(double value)
00135 {
00136 logFrequency_ = value;
00137 }
00139 void setSubMilpLogLevel(int value)
00140 {
00141 subMilpLogLevel_ = value;
00142 }
00143 private:
00145 void setTheNodeLimit();
00147 void setTimeLimit(double time) const;
00149 void setCutoff(double cutoff) const;
00151 double siBestObj(CbcModel * model=NULL) const;
00153 IpoptInterface * nlp_;
00155 mutable int nSolve_;
00157 mutable OsiSolverInterface * si_;
00159 double cbcCutoffIncrement_;
00161 double cbcIntegerTolerance_;
00163 int localSearchNodeLimit_;
00165 int maxLocalSearchPerNode_;
00167 int maxLocalSearch_;
00169 double maxLocalSearchTime_;
00171 mutable int nLocalSearch_;
00173 bool solveAuxiliaryProblem_;
00175 CoinMessageHandler * handler_;
00177 CoinMessages messages_;
00179 int subMilpLogLevel_;
00181 bool leaveSiUnchanged_;
00183 CbcStrategy * strategy_;
00185 double timeBegin_;
00187 double logFrequency_;
00188 };
00189 #endif