Bonmin
1.7
|
00001 // (C) Copyright International Business Machines (IBM) 2006 00002 // All Rights Reserved. 00003 // This code is published under the Common Public License. 00004 // 00005 // Authors : 00006 // P. Bonami, International Business Machines 00007 // 00008 // Date : 12/07/2006 00009 00010 00011 // Code separated from BonOaDecBase to try to clarify OAs 00012 #ifndef BonSubMipSolver_HPP 00013 #define BonSubMipSolver_HPP 00014 #include "IpSmartPtr.hpp" 00015 #include <string> 00016 /* forward declarations.*/ 00017 class OsiSolverInterface; 00018 class OsiClpSolverInterface; 00019 class OsiCpxSolverInterface; 00020 class CbcStrategy; 00021 class CbcStrategyDefault; 00022 00023 #include "OsiCuts.hpp" 00024 00025 namespace Bonmin { 00026 class RegisteredOptions; 00027 class BabSetupBase; 00029 class SubMipSolver 00030 { 00031 public: 00032 enum MILP_solve_strategy{ 00033 FindGoodSolution, 00034 GetOptimum}; 00036 SubMipSolver(BabSetupBase &b, const std::string &prefix); 00037 00039 SubMipSolver(const SubMipSolver ©); 00040 00041 ~SubMipSolver(); 00042 00044 void setLpSolver(OsiSolverInterface * lp); 00045 00047 void setStrategy(CbcStrategyDefault * strategy); 00048 00050 const double * getLastSolution() 00051 { 00052 return integerSolution_; 00053 } 00054 00055 double getLowerBound() 00056 { 00057 return lowBound_; 00058 } 00059 00060 void solve(double cutoff, 00061 int loglevel, 00062 double maxTime){ 00063 if(milp_strat_ == FindGoodSolution){ 00064 find_good_sol(cutoff, loglevel, maxTime); 00065 } 00066 else 00067 optimize(cutoff, loglevel, maxTime); 00068 } 00069 00070 00072 void find_good_sol(double cutoff, 00073 int loglevel, 00074 double maxTime); 00075 00077 void optimize(double cutoff, 00078 int loglevel, 00079 double maxTime); 00080 00082 void optimize_with_lazy_constraints(double cutoff, 00083 int loglevel, 00084 double maxTime, const OsiCuts & cs); 00085 00087 inline double lowBound() 00088 { 00089 return lowBound_; 00090 } 00091 00093 inline bool optimal() 00094 { 00095 return optimal_; 00096 } 00097 00099 inline int nodeCount() 00100 { 00101 return nodeCount_; 00102 } 00103 00105 inline int iterationCount() 00106 { 00107 return iterationCount_; 00108 } 00109 00110 00111 OsiSolverInterface * solver(); 00112 00114 static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions); 00115 private: 00117 OsiClpSolverInterface *clp_; 00119 OsiCpxSolverInterface * cpx_; 00121 double lowBound_; 00123 bool optimal_; 00125 double * integerSolution_; 00127 CbcStrategyDefault * strategy_; 00129 int nodeCount_; 00131 int iterationCount_; 00133 MILP_solve_strategy milp_strat_; 00135 double gap_tol_; 00137 bool ownClp_; 00138 }; 00139 00140 } 00141 00142 #endif 00143