Couenne  0.5.8
CouenneDisjCuts.hpp
Go to the documentation of this file.
1 /* $Id: CouenneDisjCuts.hpp 945 2013-04-06 20:25:21Z stefan $
2  *
3  * Name: CouenneDisjCuts.hpp
4  * Author: Pietro Belotti
5  * Purpose: a generator of disjunctive cuts for MINLP problems
6  *
7  * (C) Carnegie-Mellon University, 2008.
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #ifndef COUENNE_DISJUNCTIVE_CUTS_HPP
12 #define COUENNE_DISJUNCTIVE_CUTS_HPP
13 
14 #include "BonRegisteredOptions.hpp"
15 
16 #include "OsiSolverInterface.hpp"
17 #include "CglConfig.h"
18 #include "CglCutGenerator.hpp"
20 #include "BonBabSetupBase.hpp"
21 #include "BonBabInfos.hpp"
22 #include "OsiChooseVariable.hpp"
23 #include "CouenneTypes.hpp"
24 #include "CouenneJournalist.hpp"
25 
26 namespace Couenne {
27 
28 class CouenneCutGenerator;
29 
31 
33 
35 
36  protected:
37 
40 
42  mutable int nrootcuts_;
43 
45  mutable int ntotalcuts_;
46 
48  mutable double septime_;
49 
51  mutable double objValue_;
52 
56 
59 
62 
65 
67  mutable int numDisjunctions_;
68 
71 
74 
77 
80 
83 
86 
89 
91  double cpuTime_;
92 
93  public:
94 
97  Bonmin::BabSetupBase *base = NULL,
98  CouenneCutGenerator *cg = NULL,
99  OsiChooseVariable *bcv = NULL,
100  bool is_strong = false,
101  JnlstPtr journalist = NULL,
102  const Ipopt::SmartPtr<Ipopt::OptionsList> options = NULL);
103 
106 
109 
112  {return new CouenneDisjCuts (*this);}
113 
116  {return couenneCG_;}
117 
120  OsiCuts &,
121  const CglTreeInfo = CglTreeInfo ())
122 #if CGL_VERSION_MAJOR == 0 && CGL_VERSION_MINOR <= 57
123  const
124 #endif
125  ;
126 
129 
131  inline ConstJnlstPtr Jnlst() const
132  {return ConstPtr (jnlst_);}
133 
135  int getDisjunctions (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjunctions,
136  OsiSolverInterface &si,
137  OsiCuts &cs,
138  const CglTreeInfo &info) const;
139 
142  OsiSolverInterface &si,
143  OsiCuts &cs,
144  const CglTreeInfo &info) const;
145 
147  int generateDisjCuts (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjs,
148  OsiSolverInterface &si,
149  OsiCuts &cs,
150  const CglTreeInfo &info) const;
151 
153  int checkDisjSide (OsiSolverInterface &si, OsiCuts *cuts) const;
154 
157  OsiCuts *left, OsiCuts *right,
158  CoinPackedVector &lower, CoinPackedVector &upper) const;
159 
160 protected:
161 
164 
166  void mergeBoxes (int dir, // direction (negative for "<", positive for ">")
167  CoinPackedVector &left, // input
168  CoinPackedVector &right, // input
169  CoinPackedVector merged) const; // output
170 
173  OsiCuts *cuts) const;
174 
177  OsiColCut *cut) const;
178 
179  // construct reduced, standard form matrix M from coefficient matrix of si
181  CoinPackedVector &r,
182  OsiSolverInterface &si) const;
183 
187  OsiCuts *cuts,
188  int displRow,
189  int displRhs) const;
190 };
191 
192 
194 inline void CoinInvN (register const double *orig,
195  register int n,
196  register double *inverted) {
197 
198  while (n--) *inverted++ = - *orig++;
199 }
200 
201 
203 inline void CoinCopyDisp (register const int *src,
204  register int num,
205  register int *dst,
206  register int displacement) {
207  while (num--)
208  *dst++ = *src++ + displacement;
209 }
210 
211 }
212 
213 #endif
BonBabInfos.hpp
Couenne::CoinInvN
void CoinInvN(register const double *orig, register int n, register double *inverted)
invert all contents
Definition: CouenneDisjCuts.hpp:194
Couenne::CouenneDisjCuts::clone
CouenneDisjCuts * clone() const
clone method (necessary for the abstract CglCutGenerator class)
Definition: CouenneDisjCuts.hpp:111
OsiChooseVariable.hpp
Couenne::CouenneDisjCuts::ntotalcuts_
int ntotalcuts_
total number of cuts generated
Definition: CouenneDisjCuts.hpp:45
Couenne::CouenneDisjCuts::isBranchingStrong_
bool isBranchingStrong_
Is branchMethod_ referred to a strong branching scheme?
Definition: CouenneDisjCuts.hpp:61
Couenne::CouenneDisjCuts::initDisjPercentage_
double initDisjPercentage_
Initial percentage of objects to use for generating cuts, in [0,1].
Definition: CouenneDisjCuts.hpp:70
CglTreeInfo
CoinPackedVector
Couenne::CouenneDisjCuts::jnlst_
JnlstPtr jnlst_
SmartPointer to the Journalist.
Definition: CouenneDisjCuts.hpp:64
Couenne::CouenneDisjCuts::nrootcuts_
int nrootcuts_
number of cuts generated at the first call
Definition: CouenneDisjCuts.hpp:42
Couenne::CouenneDisjCuts::registerOptions
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Add list of options to be read from file.
Bonmin::OsiTMINLPInterface
Couenne::CouenneDisjCuts::depthStopSeparate_
int depthStopSeparate_
Depth of the BB tree where stop separation.
Definition: CouenneDisjCuts.hpp:79
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
Couenne::CouenneDisjCuts::cpuTime_
double cpuTime_
maximum CPU time
Definition: CouenneDisjCuts.hpp:91
Couenne::CouenneDisjCuts::getBoxUnion
int getBoxUnion(OsiSolverInterface &si, OsiCuts *left, OsiCuts *right, CoinPackedVector &lower, CoinPackedVector &upper) const
compute smallest box containing both left and right boxes.
OsiSolverInterface.hpp
Couenne::CouenneDisjCuts::activeRows_
bool activeRows_
only include active rows in CGLP
Definition: CouenneDisjCuts.hpp:82
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
Bonmin::BabSetupBase
Couenne::CouenneDisjCuts::separateWithDisjunction
int separateWithDisjunction(OsiCuts *cuts, OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo &info) const
separate couenne cuts on both sides of single disjunction
OsiChooseVariable
Couenne::CouenneDisjCuts::OsiSI2MatrVec
void OsiSI2MatrVec(CoinPackedMatrix &M, CoinPackedVector &r, OsiSolverInterface &si) const
BonRegisteredOptions.hpp
Couenne::CouenneDisjCuts::applyColCuts
void applyColCuts(OsiSolverInterface &si, OsiColCut *cut) const
our own applyColCut, single cut
OsiColCut
Couenne::CouenneDisjCuts
Cut Generator for linear convexifications.
Definition: CouenneDisjCuts.hpp:34
CglCutGenerator
Couenne::CouenneDisjCuts::mergeBoxes
void mergeBoxes(int dir, CoinPackedVector &left, CoinPackedVector &right, CoinPackedVector merged) const
utility to merge vectors into one
Couenne::CouenneDisjCuts::addPreviousCut_
bool addPreviousCut_
add previous disj cut to current CGLP?
Definition: CouenneDisjCuts.hpp:88
Couenne::CouenneDisjCuts::branchingMethod_
OsiChooseVariable * branchingMethod_
Branching scheme (if strong, we can use SB candidates)
Definition: CouenneDisjCuts.hpp:58
Ipopt::SmartPtr< Ipopt::Journalist >
Couenne::CouenneDisjCuts::couenneCG
CouenneCutGenerator * couenneCG() const
return pointer to symbolic problem
Definition: CouenneDisjCuts.hpp:115
OsiCuts
Couenne::CouenneDisjCuts::initDisjNumber_
int initDisjNumber_
Initial number of objects to use for generating cuts.
Definition: CouenneDisjCuts.hpp:73
Couenne::CouenneDisjCuts::depthLevelling_
int depthLevelling_
Depth of the BB tree where start decreasing number of objects.
Definition: CouenneDisjCuts.hpp:76
Couenne::CouenneDisjCuts::septime_
double septime_
separation time (includes generation of problem)
Definition: CouenneDisjCuts.hpp:48
OsiSolverInterface
CouenneTypes.hpp
Couenne::CouenneDisjCuts::OsiCuts2MatrVec
int OsiCuts2MatrVec(OsiSolverInterface *cglp, OsiCuts *cuts, int displRow, int displRhs) const
add CGLP columns to solver interface; return number of columns added (for later removal)
Couenne::CouenneDisjCuts::~CouenneDisjCuts
~CouenneDisjCuts()
destructor
Couenne::CouenneDisjCuts::getSingleDisjunction
OsiCuts * getSingleDisjunction(OsiSolverInterface &si) const
create single osicolcut disjunction
Couenne::CouenneDisjCuts::Jnlst
ConstJnlstPtr Jnlst() const
Provide Journalist.
Definition: CouenneDisjCuts.hpp:131
CoinPackedMatrix
ConstPtr
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
BonBabSetupBase.hpp
Couenne::CouenneDisjCuts::CouenneDisjCuts
CouenneDisjCuts(const CouenneDisjCuts &)
copy constructor
Couenne::CouenneDisjCuts::couenneCG_
CouenneCutGenerator * couenneCG_
pointer to symbolic repr. of constraint, variables, and bounds
Definition: CouenneDisjCuts.hpp:39
Couenne::CouenneDisjCuts::generateCuts
void generateCuts(const OsiSolverInterface &, OsiCuts &, const CglTreeInfo=CglTreeInfo()) const
the main CglCutGenerator
cut
Couenne::COUENNE_TIGHTENED
@ COUENNE_TIGHTENED
Definition: CouenneDisjCuts.hpp:30
Couenne::CouenneDisjCuts::getDisjunctions
int getDisjunctions(std::vector< std::pair< OsiCuts *, OsiCuts * > > &disjunctions, OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo &info) const
get all disjunctions
CglConfig.h
Couenne::COUENNE_INFEASIBLE
@ COUENNE_INFEASIBLE
Definition: CouenneDisjCuts.hpp:30
CglCutGenerator.hpp
Couenne::CouenneDisjCuts::objValue_
double objValue_
Record obj value at final point of CouenneConv.
Definition: CouenneDisjCuts.hpp:51
Couenne::CoinCopyDisp
void CoinCopyDisp(register const int *src, register int num, register int *dst, register int displacement)
a CoinCopyN with a += on each element
Definition: CouenneDisjCuts.hpp:203
Couenne::CouenneDisjCuts::minlp_
Bonmin::OsiTMINLPInterface * minlp_
nonlinear solver interface as used within Bonmin (used at first Couenne pass of each b&b node)
Definition: CouenneDisjCuts.hpp:55
Couenne::CouenneDisjCuts::checkDisjSide
int checkDisjSide(OsiSolverInterface &si, OsiCuts *cuts) const
check if (column!) cuts compatible with solver interface
Couenne::CouenneDisjCuts::activeCols_
bool activeCols_
only include active columns in CGLP
Definition: CouenneDisjCuts.hpp:85
Couenne::CouenneDisjCuts::CouenneDisjCuts
CouenneDisjCuts(Bonmin::OsiTMINLPInterface *minlp=NULL, Bonmin::BabSetupBase *base=NULL, CouenneCutGenerator *cg=NULL, OsiChooseVariable *bcv=NULL, bool is_strong=false, JnlstPtr journalist=NULL, const Ipopt::SmartPtr< Ipopt::OptionsList > options=NULL)
constructor
Couenne::CouenneDisjCuts::applyColCuts
void applyColCuts(OsiSolverInterface &si, OsiCuts *cuts) const
our own applyColCuts
Couenne::COUENNE_FEASIBLE
@ COUENNE_FEASIBLE
Definition: CouenneDisjCuts.hpp:30
BonOsiTMINLPInterface.hpp
CouenneJournalist.hpp
Couenne::CouenneDisjCuts::numDisjunctions_
int numDisjunctions_
Number of disjunction to consider at each separation.
Definition: CouenneDisjCuts.hpp:67
Couenne::CouenneDisjCuts::generateDisjCuts
int generateDisjCuts(std::vector< std::pair< OsiCuts *, OsiCuts * > > &disjs, OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo &info) const
generate one disjunctive cut from one CGLP