CouenneDisjCuts.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COUENNE_DISJUNCTIVE_CUTS_HPP
00012 #define COUENNE_DISJUNCTIVE_CUTS_HPP
00013
00014 #include "BonRegisteredOptions.hpp"
00015
00016 #include "OsiSolverInterface.hpp"
00017 #include "CglConfig.h"
00018 #include "CglCutGenerator.hpp"
00019 #include "BonOsiTMINLPInterface.hpp"
00020 #include "BonBabSetupBase.hpp"
00021 #include "BonBabInfos.hpp"
00022 #include "OsiChooseVariable.hpp"
00023 #include "CouenneTypes.hpp"
00024 #include "CouenneJournalist.hpp"
00025
00026 namespace Couenne {
00027
00028 class CouenneCutGenerator;
00029
00030 enum {COUENNE_INFEASIBLE, COUENNE_TIGHTENED, COUENNE_FEASIBLE};
00031
00033
00034 class CouenneDisjCuts: public CglCutGenerator {
00035
00036 protected:
00037
00039 CouenneCutGenerator *couenneCG_;
00040
00042 mutable int nrootcuts_;
00043
00045 mutable int ntotalcuts_;
00046
00048 mutable double septime_;
00049
00051 mutable double objValue_;
00052
00055 Bonmin::OsiTMINLPInterface *minlp_;
00056
00058 OsiChooseVariable *branchingMethod_;
00059
00061 bool isBranchingStrong_;
00062
00064 JnlstPtr jnlst_;
00065
00067 mutable int numDisjunctions_;
00068
00070 double initDisjPercentage_;
00071
00073 int initDisjNumber_;
00074
00076 int depthLevelling_;
00077
00079 int depthStopSeparate_;
00080
00082 bool activeRows_;
00083
00085 bool activeCols_;
00086
00088 bool addPreviousCut_;
00089
00091 double cpuTime_;
00092
00093 public:
00094
00096 CouenneDisjCuts (Bonmin::OsiTMINLPInterface *minlp = NULL,
00097 Bonmin::BabSetupBase *base = NULL,
00098 CouenneCutGenerator *cg = NULL,
00099 OsiChooseVariable *bcv = NULL,
00100 bool is_strong = false,
00101 JnlstPtr journalist = NULL,
00102 const Ipopt::SmartPtr<Ipopt::OptionsList> options = NULL);
00103
00105 CouenneDisjCuts (const CouenneDisjCuts &);
00106
00108 ~CouenneDisjCuts ();
00109
00111 CouenneDisjCuts *clone () const
00112 {return new CouenneDisjCuts (*this);}
00113
00115 inline CouenneCutGenerator *couenneCG () const
00116 {return couenneCG_;}
00117
00119 void generateCuts (const OsiSolverInterface &,
00120 OsiCuts &,
00121 const CglTreeInfo = CglTreeInfo ())
00122 #if CGL_VERSION_MAJOR == 0 && CGL_VERSION_MINOR <= 57
00123 const
00124 #endif
00125 ;
00126
00128 static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00129
00131 inline ConstJnlstPtr Jnlst() const
00132 {return ConstPtr (jnlst_);}
00133
00135 int getDisjunctions (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjunctions,
00136 OsiSolverInterface &si,
00137 OsiCuts &cs,
00138 const CglTreeInfo &info) const;
00139
00141 int separateWithDisjunction (OsiCuts *cuts,
00142 OsiSolverInterface &si,
00143 OsiCuts &cs,
00144 const CglTreeInfo &info) const;
00145
00147 int generateDisjCuts (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjs,
00148 OsiSolverInterface &si,
00149 OsiCuts &cs,
00150 const CglTreeInfo &info) const;
00151
00153 int checkDisjSide (OsiSolverInterface &si, OsiCuts *cuts) const;
00154
00156 int getBoxUnion (OsiSolverInterface &si,
00157 OsiCuts *left, OsiCuts *right,
00158 CoinPackedVector &lower, CoinPackedVector &upper) const;
00159
00160 protected:
00161
00163 OsiCuts *getSingleDisjunction (OsiSolverInterface &si) const;
00164
00166 void mergeBoxes (int dir,
00167 CoinPackedVector &left,
00168 CoinPackedVector &right,
00169 CoinPackedVector merged) const;
00170
00172 void applyColCuts (OsiSolverInterface &si,
00173 OsiCuts *cuts) const;
00174
00176 void applyColCuts (OsiSolverInterface &si,
00177 OsiColCut *cut) const;
00178
00179
00180 void OsiSI2MatrVec (CoinPackedMatrix &M,
00181 CoinPackedVector &r,
00182 OsiSolverInterface &si) const;
00183
00186 int OsiCuts2MatrVec (OsiSolverInterface *cglp,
00187 OsiCuts *cuts,
00188 int displRow,
00189 int displRhs) const;
00190 };
00191
00192
00194 inline void CoinInvN (register const double *orig,
00195 register int n,
00196 register double *inverted) {
00197
00198 while (n--) *inverted++ = - *orig++;
00199 }
00200
00201
00203 inline void CoinCopyDisp (register const int *src,
00204 register int num,
00205 register int *dst,
00206 register int displacement) {
00207 while (num--)
00208 *dst++ = *src++ + displacement;
00209 }
00210
00211 }
00212
00213 #endif