Bonmin
1.7
|
00001 // (C) Copyright Carnegie Mellon University 2005, 2006 00002 // All Rights Reserved. 00003 // This code is published under the Common Public License. 00004 // 00005 // Authors : 00006 // P. Bonami, Carnegie Mellon University 00007 // 00008 // Date : 05/26/2005 00009 00010 #ifndef BonOaNlpOptim_HPP 00011 #define BonOaNlpOptim_HPP 00012 #include "CglCutGenerator.hpp" 00013 #include "BonOsiTMINLPInterface.hpp" 00014 #include "BonOAMessages.hpp" 00015 #include "BonBabSetupBase.hpp" 00016 namespace Bonmin 00017 { 00019 class OaNlpOptim : public CglCutGenerator 00020 { 00021 public: 00023 OaNlpOptim(OsiTMINLPInterface * si = NULL, 00024 int maxDepth = 10, bool addOnlyViolated = false, 00025 bool globalCuts = true); 00026 00028 OaNlpOptim(BabSetupBase &b); 00030 OaNlpOptim(const OaNlpOptim ©) 00031 : 00032 CglCutGenerator(copy), 00033 nlp_(copy.nlp_), 00034 maxDepth_(copy.maxDepth_), 00035 nSolve_(0), 00036 addOnlyViolated_(copy.addOnlyViolated_), 00037 global_(copy.global_), 00038 solves_per_level_(copy.solves_per_level_) 00039 { 00040 handler_ = new CoinMessageHandler(); 00041 handler_ -> setLogLevel(copy.handler_->logLevel()); 00042 messages_ = OaMessages(); 00043 } 00044 void passInMessageHandler(const CoinMessageHandler * handler) 00045 { 00046 delete handler_; 00047 handler_ = handler->clone(); 00048 } 00050 virtual CglCutGenerator * clone() const 00051 { 00052 return new OaNlpOptim(*this); 00053 } 00054 00056 virtual ~OaNlpOptim() 00057 { 00058 if (handler_) 00059 delete handler_; 00060 } 00061 00063 void assignInterface(OsiTMINLPInterface * si); 00065 virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs, 00066 const CglTreeInfo info); 00067 00068 00069 00070 inline void setMaxDepth(int value) 00071 { 00072 maxDepth_ = value; 00073 } 00074 inline void setAddOnlyViolated(bool yesno) 00075 { 00076 addOnlyViolated_ = yesno; 00077 } 00078 inline void setGlobalCuts(bool yesno) 00079 { 00080 global_ = yesno; 00081 } 00082 inline int getNSolve() 00083 { 00084 return nSolve_; 00085 } 00087 void setLogLevel(int value) 00088 { 00089 handler_->setLogLevel(value); 00090 } 00091 00093 static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions); 00094 00095 private: 00097 OsiTMINLPInterface * nlp_; 00098 00100 int maxDepth_; 00101 00103 mutable int nSolve_; 00105 CoinMessageHandler * handler_; 00107 CoinMessages messages_; 00109 bool addOnlyViolated_; 00111 bool global_; 00113 double solves_per_level_; 00114 }; 00115 } 00116 #endif