Bonmin
1.7
|
00001 // (C) Copyright CNRS 00002 // This code is published under the Common Public License. 00003 // 00004 // Authors : 00005 // Pierre Bonami, LIF Université de la Méditérannée-CNRS 00006 // 00007 // Date : 06/18/2008 00008 00009 #ifndef BonLocalSolverBasedHeuristic_H 00010 #define BonLocalSolverBasedHeuristic_H 00011 #include "BonBonminSetup.hpp" 00012 #include "CbcHeuristic.hpp" 00013 00014 namespace Bonmin { 00015 class LocalSolverBasedHeuristic : public CbcHeuristic { 00016 public: 00018 LocalSolverBasedHeuristic(); 00019 00021 LocalSolverBasedHeuristic(BonminSetup * setup); 00022 00024 LocalSolverBasedHeuristic(const LocalSolverBasedHeuristic & other); 00025 00027 ~LocalSolverBasedHeuristic(); 00028 00030 virtual CbcHeuristic * clone() const = 0; 00031 00033 LocalSolverBasedHeuristic & operator=(const LocalSolverBasedHeuristic& rhs); 00034 00035 #if 0 00036 00037 virtual void setModel(CbcModel * model){throw -1;} 00038 #endif 00039 00040 virtual void resetModel(CbcModel * model){ 00041 setModel(model); 00042 } 00043 00045 void setSetup(BonminSetup * setup){ 00046 setup_ = setup; 00047 Initialize(setup_->options()); 00048 } 00050 virtual int solution(double & objectiveValue, 00051 double * newSolution)=0; 00052 00054 virtual int solution(double & objectiveValue, 00055 double * newSolution, 00056 OsiCuts & cs) {return 0;} 00057 00058 00060 int doLocalSearch(OsiTMINLPInterface * solver, 00061 double *solution, 00062 double & solValue, 00063 double cutoff, std::string prefix = "local_solver.") const; 00064 00066 static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions); 00067 00069 virtual void setupDefaults(Ipopt::SmartPtr<Ipopt::OptionsList> options); 00070 00072 void Initialize(Ipopt::SmartPtr<Ipopt::OptionsList> options); 00073 protected: 00075 BonminSetup * setup_; 00076 00077 static void changeIfNotSet(Ipopt::SmartPtr<Ipopt::OptionsList> options, 00078 std::string prefix, 00079 const std::string &option, 00080 const std::string &value); 00081 00082 static void changeIfNotSet(Ipopt::SmartPtr<Ipopt::OptionsList> options, 00083 std::string prefix, 00084 const std::string &option, 00085 const double &value); 00086 00087 static void changeIfNotSet(Ipopt::SmartPtr<Ipopt::OptionsList> options, 00088 std::string prefix, 00089 const std::string &option, 00090 const int &value); 00091 private: 00093 double time_limit_; 00095 int max_number_nodes_; 00097 int max_number_solutions_; 00098 }; 00099 } 00101 #endif 00102