Bonmin  1.8.8
BonLocalSolverBasedHeuristic.hpp
Go to the documentation of this file.
1 // (C) Copyright CNRS
2 // This code is published under the Eclipse Public License.
3 //
4 // Authors :
5 // Pierre Bonami, LIF Université de la Méditérannée-CNRS
6 //
7 // Date : 06/18/2008
8 
9 #ifndef BonLocalSolverBasedHeuristic_H
10 #define BonLocalSolverBasedHeuristic_H
11 #include "BonBonminSetup.hpp"
12 #include "CbcHeuristic.hpp"
13 
14 namespace Bonmin {
15  class LocalSolverBasedHeuristic : public CbcHeuristic {
16  public:
19 
22 
25 
28 
30  virtual CbcHeuristic * clone() const = 0;
31 
34 
35 #if 0
36  virtual void setModel(CbcModel * model){throw -1;}
38 #endif
39  virtual void resetModel(CbcModel * model){
41  setModel(model);
42  }
43 
45  void setSetup(BonminSetup * setup){
46  setup_ = setup;
48  }
50  virtual int solution(double & objectiveValue,
51  double * newSolution)=0;
52 
54  virtual int solution(double & objectiveValue,
55  double * newSolution,
56  OsiCuts & cs) {return 0;}
57 
58 
60  int doLocalSearch(OsiTMINLPInterface * solver,
61  double *solution,
62  double & solValue,
63  double cutoff, std::string prefix = "local_solver.") const;
64 
66  static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
67 
69  virtual void setupDefaults(Ipopt::SmartPtr<Ipopt::OptionsList> options);
70 
72  void Initialize(Ipopt::SmartPtr<Ipopt::OptionsList> options);
73  protected:
76 
77  static void changeIfNotSet(Ipopt::SmartPtr<Ipopt::OptionsList> options,
78  std::string prefix,
79  const std::string &option,
80  const std::string &value);
81 
82  static void changeIfNotSet(Ipopt::SmartPtr<Ipopt::OptionsList> options,
83  std::string prefix,
84  const std::string &option,
85  const double &value);
86 
87  static void changeIfNotSet(Ipopt::SmartPtr<Ipopt::OptionsList> options,
88  std::string prefix,
89  const std::string &option,
90  const int &value);
91  private:
93  double time_limit_;
98  };
99 }
101 #endif
102 
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
virtual int solution(double &objectiveValue, double *newSolution, OsiCuts &cs)
Performs heuristic which adds cuts.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
int max_number_nodes_
maximal number of nodes in local search.
double time_limit_
Time limit in local search.
static void changeIfNotSet(Ipopt::SmartPtr< Ipopt::OptionsList > options, std::string prefix, const std::string &option, const std::string &value)
int doLocalSearch(OsiTMINLPInterface *solver, double *solution, double &solValue, double cutoff, std::string prefix="local_solver.") const
Do a local search based on setup and passed solver.
LocalSolverBasedHeuristic()
Default constructor.
void Initialize(Ipopt::SmartPtr< Ipopt::OptionsList > options)
Initiaize using passed options.
virtual void setupDefaults(Ipopt::SmartPtr< Ipopt::OptionsList > options)
Setup the defaults.
virtual int solution(double &objectiveValue, double *newSolution)=0
Performs heuristic.
void setSetup(BonminSetup *setup)
Change setup used for heuristic.
LocalSolverBasedHeuristic & operator=(const LocalSolverBasedHeuristic &rhs)
Assignment operator.
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
int max_number_solutions_
Maximal number of solutions in local search.
virtual CbcHeuristic * clone() const =0
Virtual copy constructor.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options common to all local search based heuristics.
BonminSetup * setup_
Setup to use for local searches (will make copies).