Bonmin  1.8.8
BonOaNlpOptim.hpp
Go to the documentation of this file.
1 // (C) Copyright Carnegie Mellon University 2005, 2006
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // P. Bonami, Carnegie Mellon University
7 //
8 // Date : 05/26/2005
9 
10 #ifndef BonOaNlpOptim_HPP
11 #define BonOaNlpOptim_HPP
12 #include "CglCutGenerator.hpp"
14 #include "BonOAMessages.hpp"
15 #include "BonBabSetupBase.hpp"
16 namespace Bonmin
17 {
19  class OaNlpOptim : public CglCutGenerator
20  {
21  public:
23  OaNlpOptim(OsiTMINLPInterface * si = NULL,
24  int maxDepth = 10, bool addOnlyViolated = false,
25  bool globalCuts = true);
26 
30  OaNlpOptim(const OaNlpOptim &copy)
31  :
32  CglCutGenerator(copy),
33  nlp_(copy.nlp_),
34  maxDepth_(copy.maxDepth_),
35  nSolve_(0),
37  global_(copy.global_),
39  {
40  handler_ = new CoinMessageHandler();
41  handler_ -> setLogLevel(copy.handler_->logLevel());
43  }
44  void passInMessageHandler(const CoinMessageHandler * handler)
45  {
46  delete handler_;
47  handler_ = handler->clone();
48  }
50  virtual CglCutGenerator * clone() const
51  {
52  return new OaNlpOptim(*this);
53  }
54 
56  virtual ~OaNlpOptim()
57  {
58  if (handler_)
59  delete handler_;
60  }
61 
65  virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
66  const CglTreeInfo info);
67 
68 
69 
70  inline void setMaxDepth(int value)
71  {
72  maxDepth_ = value;
73  }
74  inline void setAddOnlyViolated(bool yesno)
75  {
76  addOnlyViolated_ = yesno;
77  }
78  inline void setGlobalCuts(bool yesno)
79  {
80  global_ = yesno;
81  }
82  inline int getNSolve()
83  {
84  return nSolve_;
85  }
87  void setLogLevel(int value)
88  {
89  handler_->setLogLevel(value);
90  }
91 
93  static void registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions);
94 
95  private:
98 
101 
103  mutable int nSolve_;
105  CoinMessageHandler * handler_;
107  CoinMessages messages_;
111  bool global_;
114  };
115 }
116 #endif
bool addOnlyViolated_
Add only violated cuts?
void assignInterface(OsiTMINLPInterface *si)
Assign an OsiTMINLPInterface.
void setGlobalCuts(bool yesno)
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
void setLogLevel(int value)
set log level
void setMaxDepth(int value)
double solves_per_level_
Average number of nodes per level in tree.
OsiTMINLPInterface * nlp_
Pointer to the Ipopt interface.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register OaNlpOptim options.
virtual CglCutGenerator * clone() const
Abstract constructor.
A class to have all elements necessary to setup a branch-and-bound.
bool global_
Add cuts as global?
CoinMessageHandler * handler_
messages handler.
CoinMessages messages_
handler
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info)
cut generation method
int nSolve_
Number of NLP resolution done.
int maxDepth_
maximum depth at which generate cuts
Output messages for Outer approximation cutting planes.
OaNlpOptim(OsiTMINLPInterface *si=NULL, int maxDepth=10, bool addOnlyViolated=false, bool globalCuts=true)
Default constructor.
OaNlpOptim(const OaNlpOptim &copy)
Copy constructor.
virtual ~OaNlpOptim()
Desctructor.
void passInMessageHandler(const CoinMessageHandler *handler)
Generate cuts for the nlp corresponding to continuous relaxation at a node.
void setAddOnlyViolated(bool yesno)