source: trunk/Bonmin/src/OaInterface/IpCbcOACutGenerator2.hpp @ 1

Last change on this file since 1 was 1, checked in by andreasw, 13 years ago

imported initial code

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 5.1 KB
Line 
1// (C) Copyright Carnegie Mellon University 2005
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// Authors :
6// P. Bonami, Carnegie Mellon University
7//
8// Date :  05/26/2005
9
10
11#ifndef IpCbcOACutGenerator2_HPP
12#define IpCbcOACutGenerator2_HPP
13#include "CglCutGenerator.hpp"
14#include "IpoptInterface.hpp"
15#include "OaMessages.hpp"
16#include "CbcModel.hpp"
17
18#include "CbcStrategy.hpp"
19
20#include "CoinTime.hpp"
21
22
23class IpCbcOACutGenerator2 : public CglCutGenerator
24{
25public:
26  typedef enum subSolver {Clp, Cbc, Cplex, Other};
27  /// Default constructor
28  IpCbcOACutGenerator2();
29  /// Usefull constructor
30  IpCbcOACutGenerator2(IpoptInterface * nlp = NULL,
31      OsiSolverInterface * si = NULL,
32      CbcStrategy * strategy = NULL,
33      double cbcCutoffIncrement_=1e-07,
34      double cbcIntegerTolerance = 1e-05,
35      bool solveAuxiliaryProblem = 1,
36      bool leaveSiUnchanged = 0
37                      );
38
39  /// Copy constructor
40  IpCbcOACutGenerator2(const IpCbcOACutGenerator2 &copy)
41      :nlp_(copy.nlp_),
42      si_(copy.si_),
43      cbcCutoffIncrement_(copy.cbcCutoffIncrement_),
44      cbcIntegerTolerance_(copy.cbcIntegerTolerance_),
45      localSearchNodeLimit_(copy.localSearchNodeLimit_),
46      maxLocalSearchPerNode_(copy.maxLocalSearchPerNode_),
47      maxLocalSearch_(copy.maxLocalSearch_),
48      maxLocalSearchTime_(copy.maxLocalSearchTime_),
49      nLocalSearch_(copy.nLocalSearch_),
50      solveAuxiliaryProblem_(copy.solveAuxiliaryProblem_),
51      handler_(NULL), messages_(copy.messages_),
52      subMilpLogLevel_(copy.subMilpLogLevel_),
53      leaveSiUnchanged_(copy.leaveSiUnchanged_),
54      strategy_(NULL),
55      timeBegin_(0.),
56      logFrequency_(copy.logFrequency_)
57  {
58    handler_ = new CoinMessageHandler();
59    handler_->setLogLevel(copy.handler_->logLevel());
60    if(copy.strategy_)
61      strategy_ = copy.strategy_->clone();
62    timeBegin_ = CoinCpuTime();
63  }
64  /// Destructor
65  ~IpCbcOACutGenerator2();
66
67  /// Assign an IpoptInterface
68  void assignNlpInterface(IpoptInterface * nlp);
69
70  /// Assign an IpoptInterface
71  void assignLpInterface(OsiSolverInterface * si);
72
73  void setStrategy(const CbcStrategy & strategy)
74  {
75    if(strategy_)
76      delete strategy_;
77    strategy_ = strategy.clone();
78  }
79  /// cut generation method
80  virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
81      const CglTreeInfo info = CglTreeInfo()) const;
82
83  virtual CglCutGenerator * clone() const
84  {
85    return new IpCbcOACutGenerator2(*this);
86  }
87
88  inline int getNSolve()
89  {
90    return nSolve_;
91  }
92  /// Set value for cutoff increment
93  void setcbcCutoffIncrement (double value)
94  {
95    cbcCutoffIncrement_ = value;
96  }
97  /// Set value for integer tolerance
98  void setcbcIntegerTolerance (double value)
99  {
100    cbcIntegerTolerance_ = value;
101  }
102  ///set max number of nodes for local search
103  void setLocalSearchNodeLimit(int value)
104  {
105    localSearchNodeLimit_ = value;
106    if(si_)
107      setTheNodeLimit();
108  }
109  ///set max number of local searches per node
110  void setMaxLocalSearchPerNode(int value)
111  {
112    maxLocalSearchPerNode_ = value;
113  }
114  ///set total max number of local searches
115  void setMaxLocalSearch(int value)
116  {
117    maxLocalSearch_ = value;
118  }
119
120  void setMaxLocalSearchTime(double time)
121  {
122    maxLocalSearchTime_ = time;
123  }
124  /**set log level */
125  void setLogLevel(int value)
126  {
127    handler_->setLogLevel(value);
128  }
129  /** Set log frequency.*/
130  void setLogFrequency(double value)
131  {
132    logFrequency_ = value;
133  }
134  /**set log level */
135  void setSubMilpLogLevel(int value)
136  {
137    subMilpLogLevel_ = value;
138  }
139private:
140  /// Set the node limit to the interface
141  void setTheNodeLimit();
142  /// Set the time limit for b&b
143  void setTimeLimit(double time) const;
144  /// Set the cutoff for b&b
145  void setCutoff(double cutoff) const;
146  /// Get bound on the solution value after doing partial local search
147  double siBestObj(CbcModel * model=NULL) const;
148  /// Pointer to the Ipopt interface
149  IpoptInterface * nlp_;
150  ///Number of NLP resolution done
151  mutable int nSolve_;
152  /// A linear solver
153  mutable OsiSolverInterface * si_;
154  /// cutoff min increase (has to be intialized trhough Cbc)
155  double cbcCutoffIncrement_;
156  /// integer tolerance (has to be the same as Cbc's)
157  double cbcIntegerTolerance_;
158  ///Max number of nodes for local search
159  int localSearchNodeLimit_;
160  ///Max number of local searches per node
161  int maxLocalSearchPerNode_;
162  ///Total max number of local searches
163  int maxLocalSearch_;
164  /// maximum time for local searches
165  double maxLocalSearchTime_;
166  ///number of local searches performed
167  mutable int nLocalSearch_;
168  ///set to 1 to solve  an auxiliary NLP when infeasible assignment is encountered
169  bool solveAuxiliaryProblem_;
170  /** messages handler. */
171  CoinMessageHandler * handler_;
172  /** handler */
173  CoinMessages messages_;
174  /** sub milp log level.*/
175  int subMilpLogLevel_;
176  /** Wether or not we should remove cuts at the end of the procedure */
177  bool leaveSiUnchanged_;
178  /** Strategy to apply when using Cbc as MILP sub-solver.*/
179  CbcStrategy * strategy_;
180  /** time of construction*/
181  double timeBegin_;
182  /** Frequency of log. */
183  double logFrequency_;
184};
185#endif
Note: See TracBrowser for help on using the repository browser.