Bonmin  1.8.7
BonBabSetupBase.hpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines Corporation 2007
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, International Business Machines Corporation
7 //
8 // Date : 04/12/2007
9 
10 #ifndef BabSetupBase_H
11 #define BabSetupBase_H
12 
13 #include <string>
14 #include <list>
15 #include "CglCutGenerator.hpp"
16 #include "CbcHeuristic.hpp"
17 #include "OsiChooseVariable.hpp"
19 #include "IpSmartPtr.hpp"
20 #include "BonTMINLP2OsiLP.hpp"
21 
22 namespace Bonmin
23 {
26  {
27  public:
29  struct CuttingMethod
30  {
31  int frequency;
32  std::string id;
34  bool atSolution;
35  bool normal;
36  bool always;
38  atSolution(false),
39  normal(true),
40  always(false)
41  {}
42 
43  CuttingMethod(const CuttingMethod & other):
44  frequency(other.frequency),
45  id(other.id),
46  cgl(other.cgl),
47  atSolution(other.atSolution),
48  normal(other.normal),
49  always(other.always)
50  {}
51  };
54  {
55  std::string id;
56  CbcHeuristic* heuristic;
58  {}
59 
61  id(other.id),
62  heuristic(other.heuristic)
63  {}
64  };
65  typedef std::list<CuttingMethod> CuttingMethods;
66  typedef std::list<HeuristicMethod > HeuristicMethods;
67 
70  bestBound = 0 ,
71  DFS ,
72  BFS ,
76  };
77 
85  };
86 
87 
93 #ifdef BONMIN_CURVATURE_BRANCHING
94  CURVATURE_ESTIMATOR,
95 #endif
102  };
103 
123  };
124 
125 
135  };
136 
138  BabSetupBase(const CoinMessageHandler * handler = NULL);
139 
141  BabSetupBase(Ipopt::SmartPtr<TMINLP> tminlp, const CoinMessageHandler * handler = NULL);
145  BabSetupBase(const OsiTMINLPInterface& nlp);
147  BabSetupBase(const BabSetupBase &setup,
148  OsiTMINLPInterface &nlp);
149 
151  BabSetupBase(const BabSetupBase &setup,
152  OsiTMINLPInterface &nlp,
153  const std::string &prefix);
154 
156  BabSetupBase(const BabSetupBase & other);
157 
159  virtual BabSetupBase * clone() const = 0;
160 
162  virtual BabSetupBase *clone(OsiTMINLPInterface&nlp)const;
164  virtual ~BabSetupBase();
165 
169  void use(const OsiTMINLPInterface& nlp);
171  void use(Ipopt::SmartPtr<TMINLP> tminlp );
176  {
177  nonlinearSolver_ = s;
178  }
184  virtual void registerOptions();
187  {}
190 
192  virtual void readOptionsFile()
193  {
194  if (readOptions_) return;
195  readOptionsFile("bonmin.opt");
196  }
197 
199  void readOptionsFile(std::string fileName);
200 
202  void readOptionsString(std::string opt_string);
203 
205  void readOptionsStream(std::istream& is);
206 
208  void mayPrintDoc();
209 
210 
212  const char * prefix() const {
213  return prefix_.c_str();
214  }
215 
220  {
221  options_ = options;
224  }
225 
234  {
235  return nonlinearSolver_;
236  }
239  {
240  return continuousSolver_;
241  }
244  {
245  return cutGenerators_;
246  }
249  {
250  return heuristics_;
251  }
254  {
255  return branchingMethod_;
256  }
259  {
260  return nodeComparisonMethod_;
261  }
264  {
265  return treeTraversalMethod_;
266  }
268  int getIntParameter(const IntParameter &p) const
269  {
270  return intParam_[p];
271  }
273  double getDoubleParameter(const DoubleParameter &p) const
274  {
275  return doubleParam_[p];
276  }
278  void setIntParameter(const IntParameter &p, const int v)
279  {
280  intParam_[p] = v;
281  }
283  void setDoubleParameter(const DoubleParameter &p, const double v)
284  {
285  doubleParam_[p] = v;
286  }
291  {
293  }
298  {
299  return journalist_;
300  }
301 
304  {
305  return options_;
306  }
307 
310  {
311  return roptions_;
312  }
313 
316  {
317  return objects_;
318  }
319 
322  {
323  return objects_;
324  }
325 
327  cutGenerators_.push_back(cg);
328  }
329 
330  void set_linearizer(TMINLP2OsiLP * linearizer){
331  linearizer_ = linearizer;
332  }
333 
334  protected:
336  void setPriorities();
338  void addSos();
339 
366 
367 
370 
373 
376 
382  std::string prefix_;
383  };
384 }/* End namespace Bonmin. */
385 #endif
386 
virtual ~BabSetupBase()
Virtual destructor.
Stop if relative gap is less than this.
void addCutGenerator(CuttingMethod &cg)
CoinMessageHandler * messageHandler_
separate message handler.
void readOptionsString(std::string opt_string)
Get the options from long string containing all.
static int defaultIntParam_[NumberIntParam]
default values for int parameters.
Number of candidates for strong branching.
double doubleParam_[NumberDoubleParam]
storage of double parameters.
Same as DfsDiveFromBest, but after a prescribed number of integer solution are found switch to best-b...
vector< OsiObject * > & objects()
Access to extra objects.
dive from top node of the heap untill it gets to a leaf of the tree.
std::string prefix_
Prefix to use when reading options.
Ipopt::SmartPtr< Ipopt::Journalist > journalist_
Storage of Journalist for output.
Spetial option in particular for Cbc.
NodeComparison
Strategies for comparing the nodes on the heap.
Best guessed integer solution is subtree below, based on pseudo costs.
Max number of failures in a branch.
OsiSolverInterface * continuousSolver()
Pointer to the continuous solver to use for relaxations.
Max number of consecutive infeasible problem in a branch before fathoming.
static void registerAllOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all the options for this algorithm instance.
TreeTraversal treeTraversalMethod()
Method used to traverse tree.
void setPriorities()
Set the priorities into OsiTMINLPInterface when needed.
vector< OsiObject * > objects_
Extra object to add to Cbc (not OsiObjects).
(C) Copyright International Business Machines Corporation 2007
NodeComparison nodeComparisonMethod_
Node comparison method.
Type for heuristic method with its string identification.
static double defaultDoubleParam_[NumberDoubleParam]
default values for double parameters.
CuttingMethod(const CuttingMethod &other)
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
void initializeOptionsAndJournalist()
Initialize the options and the journalist.
Type for cut generation method with its frequency and string identification.
Behavior of the algorithm in the case of a failure.
DoubleParameter
Parameters represented by a double.
Dynamic strategy, see CbcBranchActual.hpp for explanations.
OsiChooseVariable * branchingMethod()
branching method to use.
void mayPrintDoc()
May print documentation of options if options print_options_documentation is set to yes.
Number of cut passes at nodes.
NodeComparison & nodeComparisonMethod()
Method used to compare nodes.
virtual void registerOptions()
Register all the options for this algorithm instance.
OsiChooseVariable * branchingMethod_
Branching method.
A transformer class to build outer approximations i.e.
int getIntParameter(const IntParameter &p) const
Return value of integer parameter.
void setNonlinearSolver(OsiTMINLPInterface *s)
Set the non-linear solver used.
Stop if absolute gap is less than this.
void setOptionsAndJournalist(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions, Ipopt::SmartPtr< Ipopt::OptionsList > options, Ipopt::SmartPtr< Ipopt::Journalist > journalist)
Set the value for options, output...
limit on number of integer feasible solution.
HeuristicMethods heuristics_
Heuristic methods.
TreeTraversal treeTraversalMethod_
Tree traversal method.
Ipopt::SmartPtr< Ipopt::OptionsList > options_
List of Options.
Ipopt::SmartPtr< TMINLP2OsiLP > linearizer_
Method to linearize MINLPs.
void setDoubleParameter(const DoubleParameter &p, const double v)
Return value of double parameter.
virtual BabSetupBase * clone() const =0
virtual copy constructor.
CuttingMethods & cutGenerators()
list of cutting planes methods to apply with their frequencies.
const vector< OsiObject * > & objects() const
Access to extra objects.
Consider or not SOS constraints.
OsiTMINLPInterface * nonlinearSolver_
Storage of the non-linear solver used.
const char * prefix() const
Get prefix to use for options.
Number of cut passes at nodes.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
void use(const OsiTMINLPInterface &nlp)
use existing TMINLP interface (containing the options).
dive from top node of the heap with more elaborate strategy (see options doc).
HeuristicMethod(const HeuristicMethod &other)
A class to have all elements necessary to setup a branch-and-bound.
std::list< CuttingMethod > CuttingMethods
void addSos()
Add SOS constraints to OsiTMINLPInterface when needed.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions_
Registered Options.
BabSetupBase(const CoinMessageHandler *handler=NULL)
Default constructor.
virtual void setBabDefaultOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Setup the defaults options for this algorithm.
Log level for root relaxation.
void set_linearizer(TMINLP2OsiLP *linearizer)
void gatherParametersValues()
Get the values of base parameters from the options stored.
Display information every logIntervval nodes.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions()
Access registered Options.
void setIntParameter(const IntParameter &p, const int v)
Return value of integer parameter.
IntParameter
Parameters represented by an integer.
Ipopt::SmartPtr< Ipopt::Journalist > journalist()
Acces storage of Journalist for output.
void readOptionsStream(std::istream &is)
Get the options from stream.
Minimum reliability before trust pseudo-costs.
bool readOptions_
flag to say if option file was read.
int intParam_[NumberIntParam]
storage of integer parameters.
std::list< HeuristicMethod > HeuristicMethods
HeuristicMethods & heuristics()
list of Heuristic methods to use.
TreeTraversal
Strategies for traversing the tree.
virtual void readOptionsFile()
Get the options from default text file (bonmin.opt) if don't already have them.
OsiSolverInterface * continuousSolver_
Storage of continuous solver.
double getDoubleParameter(const DoubleParameter &p) const
Return value of double parameter.
OsiTMINLPInterface * nonlinearSolver()
Pointer to the non-linear solver used.
CuttingMethods cutGenerators_
Cut generation methods.
Eplore two kids before following on dive.