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;
33  CglCutGenerator * cgl;
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  {
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  }
238  OsiSolverInterface * continuousSolver()
239  {
240  return continuousSolver_;
241  }
244  {
245  return cutGenerators_;
246  }
249  {
250  return heuristics_;
251  }
253  OsiChooseVariable * branchingMethod()
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 
351  OsiSolverInterface * continuousSolver_;
359  OsiChooseVariable * branchingMethod_;
366 
367 
370 
373 
376 
380  CoinMessageHandler * messageHandler_;
382  std::string prefix_;
383  };
384 }/* End namespace Bonmin. */
385 #endif
386 
int getIntParameter(const IntParameter &p) const
Return value of integer parameter.
Behavior of the algorithm in the case of a failure.
void readOptionsStream(std::istream &is)
Get the options from stream.
Max number of failures in a branch.
const vector< OsiObject * > & objects() const
Access to extra objects.
Depth First Search.
int intParam_[NumberIntParam]
storage of integer parameters.
Type for heuristic method with its string identification.
CuttingMethods cutGenerators_
Cut generation methods.
Ipopt::SmartPtr< Ipopt::Journalist > journalist()
Acces storage of Journalist for output.
virtual void registerOptions()
Register all the options for this algorithm instance.
VarSelectStra_Enum
Parameters represented by an integer.
void use(const OsiTMINLPInterface &nlp)
use existing TMINLP interface (containing the options).
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions()
Access registered Options.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
Stop if relative 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...
Spetial option in particular for Cbc.
HeuristicMethods heuristics_
Heuristic methods.
vector< OsiObject * > objects_
Extra object to add to Cbc (not OsiObjects).
static double defaultDoubleParam_[NumberDoubleParam]
default values for double parameters.
Same as DfsDiveFromBest, but after a prescribed number of integer solution are found switch to best-b...
Number of candidates for strong branching.
TreeTraversal treeTraversalMethod_
Tree traversal method.
bool readOptions_
flag to say if option file was read.
BabSetupBase(const CoinMessageHandler *handler=NULL)
Default constructor.
void setPriorities()
Set the priorities into OsiTMINLPInterface when needed.
OsiTMINLPInterface * nonlinearSolver_
Storage of the non-linear solver used.
Dynamic strategy, see CbcBranchActual.hpp for explanations.
Minimum reliability before trust pseudo-costs.
TreeTraversal treeTraversalMethod()
Method used to traverse tree.
Type for cut generation method with its frequency and string identification.
OsiChooseVariable * branchingMethod_
Branching method.
the MaxTime class.
Definition: OSOption.h:668
A class to have all elements necessary to setup a branch-and-bound.
limit on number of integer feasible solution.
IntParameter
Parameters represented by an integer.
std::list< CuttingMethod > CuttingMethods
NodeComparison nodeComparisonMethod_
Node comparison method.
static int defaultIntParam_[NumberIntParam]
default values for int parameters.
DoubleParameter
Parameters represented by a double.
virtual BabSetupBase * clone() const =0
virtual copy constructor.
HeuristicMethod(const HeuristicMethod &other)
OsiChooseVariable * branchingMethod()
branching method to use.
TreeTraversal
Strategies for traversing the tree.
void setNonlinearSolver(OsiTMINLPInterface *s)
Set the non-linear solver used.
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
A transformer class to build outer approximations i.e.
void set_linearizer(TMINLP2OsiLP *linearizer)
Display information every logIntervval nodes.
void addSos()
Add SOS constraints to OsiTMINLPInterface when needed.
Ipopt::SmartPtr< TMINLP2OsiLP > linearizer_
Method to linearize MINLPs.
Max number of consecutive infeasible problem in a branch before fathoming.
void setDoubleParameter(const DoubleParameter &p, const double v)
Return value of double parameter.
dive from top node of the heap untill it gets to a leaf of the tree.
virtual void setBabDefaultOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Setup the defaults options for this algorithm.
Ipopt::SmartPtr< Ipopt::OptionsList > options_
List of Options.
Consider or not SOS constraints.
Log level for root relaxation.
NodeComparison & nodeComparisonMethod()
Method used to compare nodes.
void initializeOptionsAndJournalist()
Initialize the options and the journalist.
Number of cut passes at nodes.
static void registerAllOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all the options for this algorithm instance.
double doubleParam_[NumberDoubleParam]
storage of double parameters.
NodeComparison
Strategies for comparing the nodes on the heap.
std::string prefix_
Prefix to use when reading options.
Ipopt::SmartPtr< Ipopt::Journalist > journalist_
Storage of Journalist for output.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions_
Registered Options.
OsiTMINLPInterface * nonlinearSolver()
Pointer to the non-linear solver used.
void gatherParametersValues()
Get the values of base parameters from the options stored.
void addCutGenerator(CuttingMethod &cg)
Ipopt::SmartPtr< Ipopt::OptionsList > options()
Acces list of Options.
double getDoubleParameter(const DoubleParameter &p) const
Return value of double parameter.
OsiSolverInterface * continuousSolver()
Pointer to the continuous solver to use for relaxations.
void setIntParameter(const IntParameter &p, const int v)
Return value of integer parameter.
HeuristicMethods & heuristics()
list of Heuristic methods to use.
dive from top node of the heap with more elaborate strategy (see options doc).
Eplore two kids before following on dive.
Number of cut passes at nodes.
CoinMessageHandler * messageHandler_
separate message handler.
std::list< HeuristicMethod > HeuristicMethods
virtual ~BabSetupBase()
Virtual destructor.
CuttingMethod(const CuttingMethod &other)
void mayPrintDoc()
May print documentation of options if options print_options_documentation is set to yes...
virtual void readOptionsFile()
Get the options from default text file (bonmin.opt) if don&#39;t already have them.
CuttingMethods & cutGenerators()
list of cutting planes methods to apply with their frequencies.
OsiSolverInterface * continuousSolver_
Storage of continuous solver.
const char * prefix() const
Get prefix to use for options.
Stop if absolute gap is less than this.
Best guessed integer solution is subtree below, based on pseudo costs.
vector< OsiObject * > & objects()
Access to extra objects.
void readOptionsString(std::string opt_string)
Get the options from long string containing all.