Couenne  0.5.8
CouenneCutGenerator.hpp
Go to the documentation of this file.
1 /* $Id: CouenneCutGenerator.hpp 945 2013-04-06 20:25:21Z stefan $
2  *
3  * Name: CouenneCutGenerator.hpp
4  * Author: Pietro Belotti
5  * Purpose: a convexification cut generator for MINLP problems
6  *
7  * (C) Carnegie-Mellon University, 2006-09.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_CUT_GENERATOR_HPP
12 #define COUENNE_CUT_GENERATOR_HPP
13 
14 //#include "BonRegisteredOptions.hpp"
15 
16 #include "BonOaDecBase.hpp"
17 #include "CglConfig.h"
18 #include "CglCutGenerator.hpp"
19 #include "OsiRowCut.hpp"
20 #include "BonAuxInfos.hpp"
21 #include "BonBabInfos.hpp"
22 #include "OsiSolverInterface.hpp"
23 #include "CouenneConfig.h"
24 #include "CouenneJournalist.hpp"
25 #include "CouenneTypes.hpp"
26 
27 namespace Ipopt {
28  template <class T> class SmartPtr;
29  class OptionsList;
30  class Journalist;
31 }
32 
33 namespace Bonmin {
34  class RegisteredOptions;
35  class BabInfo;
36  class OsiTMINLPInterface;
37  class BabSetupBase;
38 }
39 
40 struct ASL;
41 
42 namespace Couenne {
43 
44 class CouenneProblem;
45 class funtriplet;
46 
48 
50 
51  protected:
52 
55  mutable bool firstcall_;
56 
59  mutable bool addviolated_;
60 
62  enum conv_type convtype_;
63 
65  int nSamples_;
66 
69 
71  mutable int nrootcuts_;
72 
74  mutable int ntotalcuts_;
75 
77  mutable double septime_;
78 
80  mutable double objValue_;
81 
85 
89 
91  mutable bool infeasNode_;
92 
95 
97  mutable double rootTime_;
98 
101  bool check_lp_;
102 
106 
108  mutable int lastPrintLine;
109 
110  public:
111 
114  Bonmin::BabSetupBase *base = NULL,
115  CouenneProblem * = NULL,
116  struct ASL * = NULL);
117 
120 
123 
126  {return new CouenneCutGenerator (*this);}
127 
129  inline CouenneProblem *Problem () const
130  {return problem_;}
131 
133  inline void setProblem (CouenneProblem *p)
134  {problem_ = p;}
135 
137  int getnvars () const;
138 
140  inline bool isFirst () const
141  {return firstcall_;}
142 
144  inline bool addViolated () const
145  {return addviolated_;}
146 
148  inline enum conv_type ConvType () const
149  {return convtype_;}
150 
152  inline int nSamples () const
153  {return nSamples_;}
154 
157  OsiCuts &,
158  const CglTreeInfo = CglTreeInfo ())
159 #if CGL_VERSION_MAJOR == 0 && CGL_VERSION_MINOR <= 57
160  const
161 #endif
162  ;
163 
165  int createCut (OsiCuts &, // cutset to insert
166  CouNumber, // lb
167  CouNumber, // ub
168  // index, coeff (index -1: "don't care")
169  int, CouNumber, // of first term
170  int=-1, CouNumber=0., // of second term
171  int=-1, CouNumber=0., // of third term
172  bool = false) const; // is it a global cut? No, by default
173 
175  int createCut (OsiCuts &, // cutset to insert
176  CouNumber, // rhs
177  int, // sign: -1: <=, 0: =, +1: >=
178  // index, coeff (index -1: "don't care")
179  int, CouNumber, // of first term
180  int=-1, CouNumber=0., // of second term
181  int=-1, CouNumber=0., // of third term
182  bool = false) const; // is it a global cut? No, by default
183 
188  int,
190  int, int,
192  t_chg_bounds * = NULL,
193  bool = false) const;
194 
199  int,
200  funtriplet *,
201  int, int,
203  t_chg_bounds * = NULL,
204  bool = false) const;
205 
208  int addSegment (OsiCuts &, int, int,
210  CouNumber, CouNumber, int) const;
211 
213  int addTangent (OsiCuts &, int, int,
215  CouNumber, int) const;
216 
219  {BabPtr_ = p;}
220 
222  void getStats (int &nrc, int &ntc, double &st) {
223  nrc = nrootcuts_;
224  ntc = ntotalcuts_;
225  st = septime_;
226  }
227 
229  bool &infeasNode () const
230  {return infeasNode_;}
231 
233  void genRowCuts (const OsiSolverInterface &, OsiCuts &cs,
234  int, int *, t_chg_bounds * = NULL) const;
235 
237  void genColCuts (const OsiSolverInterface &, OsiCuts &, int, int *) const;
238 
241 
243  void printLineInfo() const;
244 
246  inline ConstJnlstPtr Jnlst() const
247  {return ConstPtr (jnlst_);}
248 
249  void setJnlst (JnlstPtr jnlst__)
250  { jnlst_ = jnlst__; }
251 
253  double &rootTime ()
254  {return rootTime_;}
255 
257  bool check_lp () const
258  {return check_lp_;}
259 
261  bool enableLpImpliedBounds () const
262  {return enable_lp_implied_bounds_;}
263 };
264 
265 
267 void sparse2dense (int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged);
268 
269 }
270 
271 #endif
Bonmin::Bab
BonBabInfos.hpp
Couenne::t_chg_bounds
status of lower/upper bound of a variable, to be checked/modified in bound tightening
Definition: CouenneTypes.hpp:67
Couenne::unary_function
CouNumber(* unary_function)(CouNumber)
unary function, used in all exprUnary
Definition: CouenneTypes.hpp:103
Couenne::CouenneCutGenerator::setJnlst
void setJnlst(JnlstPtr jnlst__)
Definition: CouenneCutGenerator.hpp:249
Couenne::CouenneCutGenerator::infeasNode
bool & infeasNode() const
Allow to get and set the infeasNode_ flag (used only in generateCuts())
Definition: CouenneCutGenerator.hpp:229
Couenne::CouenneCutGenerator::infeasNode_
bool infeasNode_
signal infeasibility of current node (found through bound tightening)
Definition: CouenneCutGenerator.hpp:91
CglTreeInfo
Couenne::CouenneCutGenerator::firstcall_
bool firstcall_
True if no convexification cuts have been generated yet for this problem.
Definition: CouenneCutGenerator.hpp:55
BonAuxInfos.hpp
Couenne::CouenneCutGenerator::lastPrintLine
int lastPrintLine
Running count of printed info lines.
Definition: CouenneCutGenerator.hpp:108
Couenne::CouenneCutGenerator::jnlst_
JnlstPtr jnlst_
SmartPointer to the Journalist.
Definition: CouenneCutGenerator.hpp:94
Bonmin
Couenne::sparse2dense
void sparse2dense(int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged)
translate sparse to dense vector (should be replaced)
Couenne::funtriplet
Definition: CouenneFunTriplets.hpp:22
Couenne::CouenneCutGenerator::convtype_
enum conv_type convtype_
what kind of sampling should be performed?
Definition: CouenneCutGenerator.hpp:62
Bonmin::OsiTMINLPInterface
Ipopt
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
CouenneConfig.h
OsiSolverInterface.hpp
Couenne::CouenneCutGenerator::nlp_
Bonmin::OsiTMINLPInterface * nlp_
nonlinear solver interface as used within Bonmin (used at first Couenne pass of each b&b node
Definition: CouenneCutGenerator.hpp:84
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
Couenne::CouenneCutGenerator::clone
CouenneCutGenerator * clone() const
clone method (necessary for the abstract CglCutGenerator class)
Definition: CouenneCutGenerator.hpp:125
Bonmin::BabSetupBase
Couenne::CouenneCutGenerator::addTangent
int addTangent(OsiCuts &, int, int, CouNumber, CouNumber, CouNumber, int) const
add tangent at given poing (x,w) with given slope
Couenne::CouenneCutGenerator::createCut
int createCut(OsiCuts &, CouNumber, int, int, CouNumber, int=-1, CouNumber=0., int=-1, CouNumber=0., bool=false) const
create cut and check violation. Other version with only one bound
Couenne::CouenneCutGenerator::addEnvelope
void addEnvelope(OsiCuts &, int, funtriplet *, int, int, CouNumber, CouNumber, CouNumber, t_chg_bounds *=NULL, bool=false) const
Add general linear envelope to convex function, given its variables' indices, the (univariate) functi...
Couenne::CouenneCutGenerator::check_lp
bool check_lp() const
return check_lp flag (used in CouenneSolverInterface)
Definition: CouenneCutGenerator.hpp:257
Couenne::CouenneCutGenerator::CouenneCutGenerator
CouenneCutGenerator(const CouenneCutGenerator &)
copy constructor
Couenne::CouenneCutGenerator::setBabPtr
void setBabPtr(Bonmin::Bab *p)
Method to set the Bab pointer.
Definition: CouenneCutGenerator.hpp:218
CglCutGenerator
Couenne::CouenneCutGenerator::isFirst
bool isFirst() const
has generateCuts been called yet?
Definition: CouenneCutGenerator.hpp:140
Ipopt::SmartPtr< Ipopt::Journalist >
OsiRowCut.hpp
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition: CouenneTypes.hpp:100
Couenne::CouenneCutGenerator::addViolated
bool addViolated() const
should we add the violated cuts only (true), or all of them (false)?
Definition: CouenneCutGenerator.hpp:144
Couenne::CouenneCutGenerator::getStats
void getStats(int &nrc, int &ntc, double &st)
Get statistics.
Definition: CouenneCutGenerator.hpp:222
Couenne::CouenneCutGenerator::septime_
double septime_
separation time (includes generation of problem)
Definition: CouenneCutGenerator.hpp:77
OsiCuts
Couenne::CouenneCutGenerator::addSegment
int addSegment(OsiCuts &, int, int, CouNumber, CouNumber, CouNumber, CouNumber, int) const
Add half-plane through (x1,y1) and (x2,y2) – resp.
Couenne::CouenneCutGenerator::CouenneCutGenerator
CouenneCutGenerator(Bonmin::OsiTMINLPInterface *=NULL, Bonmin::BabSetupBase *base=NULL, CouenneProblem *=NULL, struct ASL *=NULL)
constructor
Couenne::conv_type
conv_type
position and number of convexification cuts added for a lower convex (upper concave) envelope
Definition: CouenneTypes.hpp:37
Couenne::CouenneCutGenerator::registerOptions
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Add list of options to be read from file.
Couenne::CouenneCutGenerator::createCut
int createCut(OsiCuts &, CouNumber, CouNumber, int, CouNumber, int=-1, CouNumber=0., int=-1, CouNumber=0., bool=false) const
create cut and check violation. Insert and return status
Couenne::CouenneCutGenerator::printLineInfo
void printLineInfo() const
print node, depth, LB/UB/LP info
Couenne::CouenneCutGenerator::BabPtr_
Bonmin::Bab * BabPtr_
pointer to the Bab object (used to retrieve the current primal bound through bestObj())
Definition: CouenneCutGenerator.hpp:88
OsiSolverInterface
CouenneTypes.hpp
Couenne::CouenneCutGenerator::Jnlst
ConstJnlstPtr Jnlst() const
Provide Journalist.
Definition: CouenneCutGenerator.hpp:246
Couenne::CouenneCutGenerator::nrootcuts_
int nrootcuts_
number of cuts generated at the first call
Definition: CouenneCutGenerator.hpp:71
ConstPtr
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Couenne::CouenneCutGenerator::ntotalcuts_
int ntotalcuts_
total number of cuts generated
Definition: CouenneCutGenerator.hpp:74
Couenne::CouenneCutGenerator::rootTime
double & rootTime()
Time spent at root node.
Definition: CouenneCutGenerator.hpp:253
Couenne::CouenneCutGenerator::objValue_
double objValue_
Record obj value at final point of CouenneConv.
Definition: CouenneCutGenerator.hpp:80
Couenne::CouenneCutGenerator::addviolated_
bool addviolated_
True if we should add the violated cuts only, false if all of them should be added.
Definition: CouenneCutGenerator.hpp:59
Couenne::CouenneCutGenerator::Problem
CouenneProblem * Problem() const
return pointer to symbolic problem
Definition: CouenneCutGenerator.hpp:129
CglConfig.h
Couenne::CouenneCutGenerator::problem_
CouenneProblem * problem_
pointer to symbolic repr. of constraint, variables, and bounds
Definition: CouenneCutGenerator.hpp:68
CglCutGenerator.hpp
Couenne::CouenneCutGenerator::ConvType
enum conv_type ConvType() const
get convexification type (see CouenneTypes.h)
Definition: CouenneCutGenerator.hpp:148
Couenne::CouenneCutGenerator::enableLpImpliedBounds
bool enableLpImpliedBounds() const
returns value of enable_lp_implied_bounds_
Definition: CouenneCutGenerator.hpp:261
Couenne::CouenneCutGenerator::addEnvelope
void addEnvelope(OsiCuts &, int, unary_function, unary_function, int, int, CouNumber, CouNumber, CouNumber, t_chg_bounds *=NULL, bool=false) const
Add general linear envelope to convex function, given its variables' indices, the (univariate) functi...
Couenne::CouenneCutGenerator::enable_lp_implied_bounds_
bool enable_lp_implied_bounds_
Take advantage of OsiClpSolverInterface::tightenBounds (), known to have caused some problems some ti...
Definition: CouenneCutGenerator.hpp:105
BonOaDecBase.hpp
Couenne::CouenneProblem
Class for MINLP problems with symbolic information.
Definition: CouenneProblem.hpp:169
Couenne::CouenneCutGenerator::getnvars
int getnvars() const
total number of variables (original + auxiliary)
Couenne::CouenneCutGenerator::nSamples_
int nSamples_
how many cuts should be added for each function?
Definition: CouenneCutGenerator.hpp:65
Couenne::CouenneCutGenerator::~CouenneCutGenerator
~CouenneCutGenerator()
destructor
Couenne::CouenneCutGenerator::generateCuts
void generateCuts(const OsiSolverInterface &, OsiCuts &, const CglTreeInfo=CglTreeInfo()) const
the main CglCutGenerator
Couenne::CouenneCutGenerator::genColCuts
void genColCuts(const OsiSolverInterface &, OsiCuts &, int, int *) const
generate OsiColCuts for improved (implied and propagated) bounds
Couenne::CouenneCutGenerator::genRowCuts
void genRowCuts(const OsiSolverInterface &, OsiCuts &cs, int, int *, t_chg_bounds *=NULL) const
generate OsiRowCuts for current convexification
Couenne::CouenneCutGenerator::setProblem
void setProblem(CouenneProblem *p)
return pointer to symbolic problem
Definition: CouenneCutGenerator.hpp:133
Couenne::CouenneCutGenerator::rootTime_
double rootTime_
Time spent at the root node.
Definition: CouenneCutGenerator.hpp:97
Couenne::CouenneCutGenerator::nSamples
int nSamples() const
get number of convexification samples
Definition: CouenneCutGenerator.hpp:152
Couenne::CouenneCutGenerator::check_lp_
bool check_lp_
Check all generated LPs through an independent call to OsiClpSolverInterface::initialSolve()
Definition: CouenneCutGenerator.hpp:101
CouenneJournalist.hpp