CouenneDisjCuts.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneDisjCuts.hpp 490 2011-01-14 16:07:12Z pbelotti $
00002  *
00003  * Name:    CouenneDisjCuts.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: a generator of disjunctive cuts for MINLP problems
00006  *
00007  * (C) Carnegie-Mellon University, 2008. 
00008  * This file is licensed under the Eclipse Public License (EPL)
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 "CglCutGenerator.hpp"
00018 #include "BonOsiTMINLPInterface.hpp"
00019 #include "BonBabSetupBase.hpp"
00020 #include "BonBabInfos.hpp"
00021 #include "OsiChooseVariable.hpp"
00022 #include "CouenneTypes.hpp"
00023 #include "CouenneJournalist.hpp"
00024 
00025 namespace Couenne {
00026 
00027 class CouenneCutGenerator;
00028 
00029 enum {COUENNE_INFEASIBLE, COUENNE_TIGHTENED, COUENNE_FEASIBLE};
00030 
00032 
00033 class CouenneDisjCuts: public CglCutGenerator {
00034 
00035  protected:
00036 
00038   CouenneCutGenerator *couenneCG_;
00039 
00041   mutable int nrootcuts_;
00042 
00044   mutable int ntotalcuts_;
00045 
00047   mutable double septime_;
00048 
00050   mutable double objValue_;
00051 
00054   Bonmin::OsiTMINLPInterface *minlp_;
00055 
00057   OsiChooseVariable *branchingMethod_;
00058 
00060   bool isBranchingStrong_;
00061 
00063   JnlstPtr jnlst_;
00064 
00066   mutable int numDisjunctions_;
00067 
00069   double initDisjPercentage_;
00070 
00072   int initDisjNumber_;
00073 
00075   int depthLevelling_;
00076 
00078   int depthStopSeparate_;
00079 
00081   bool activeRows_;
00082 
00084   bool activeCols_;
00085 
00087   bool addPreviousCut_;
00088 
00090   double cpuTime_;
00091 
00092  public:
00093 
00095   CouenneDisjCuts (Bonmin::OsiTMINLPInterface *minlp = NULL,
00096                    Bonmin::BabSetupBase *base = NULL,
00097                    CouenneCutGenerator *cg = NULL,
00098                    OsiChooseVariable *bcv = NULL,
00099                    bool is_strong = false,
00100                    JnlstPtr journalist = NULL,
00101                    const Ipopt::SmartPtr<Ipopt::OptionsList> options = NULL);
00102 
00104   CouenneDisjCuts (const CouenneDisjCuts &);
00105 
00107   ~CouenneDisjCuts ();
00108 
00110   CouenneDisjCuts *clone () const
00111   {return new CouenneDisjCuts (*this);}
00112 
00114   inline CouenneCutGenerator *couenneCG () const
00115   {return couenneCG_;}
00116 
00118   void generateCuts (const OsiSolverInterface &, 
00119                      OsiCuts &, 
00120                      const CglTreeInfo = CglTreeInfo ()) const;
00121 
00123   static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00124 
00126   inline ConstJnlstPtr Jnlst() const 
00127   {return ConstPtr (jnlst_);}
00128 
00130   int getDisjunctions (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjunctions, 
00131                        OsiSolverInterface &si, 
00132                        OsiCuts &cs, 
00133                        const CglTreeInfo &info) const;
00134 
00136   int separateWithDisjunction (OsiCuts *cuts,
00137                                OsiSolverInterface &si, 
00138                                OsiCuts &cs, 
00139                                const CglTreeInfo &info) const;
00140 
00142   int generateDisjCuts (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjs, 
00143                        OsiSolverInterface &si, 
00144                        OsiCuts &cs, 
00145                         const CglTreeInfo &info) const;
00146 
00148   int checkDisjSide (OsiSolverInterface &si, OsiCuts *cuts) const;
00149 
00151   int getBoxUnion (OsiSolverInterface &si, 
00152                    OsiCuts *left, OsiCuts *right, 
00153                    CoinPackedVector &lower, CoinPackedVector &upper) const;
00154 
00155 protected:
00156 
00158   OsiCuts *getSingleDisjunction (OsiSolverInterface &si) const;
00159 
00161   void mergeBoxes (int dir,                        // direction (negative for "<", positive for ">")
00162                    CoinPackedVector &left,         // input
00163                    CoinPackedVector &right,        // input
00164                    CoinPackedVector merged) const; // output  
00165 
00167   void applyColCuts (OsiSolverInterface &si,
00168                      OsiCuts *cuts) const;
00169 
00171   void applyColCuts (OsiSolverInterface &si, 
00172                      OsiColCut *cut) const;
00173 
00174   // construct reduced, standard form matrix M from coefficient matrix of si
00175   void OsiSI2MatrVec (CoinPackedMatrix &M,
00176                       CoinPackedVector &r,
00177                       OsiSolverInterface &si) const;
00178 
00181   int OsiCuts2MatrVec (OsiSolverInterface *cglp,
00182                        OsiCuts *cuts,
00183                        int displRow,
00184                        int displRhs) const;
00185 };
00186 
00187 
00189 inline void CoinInvN (register const double *orig, 
00190                       register int n, 
00191                       register double *inverted) {
00192 
00193   while (n--) *inverted++ = - *orig++;
00194 }
00195 
00196 
00198 inline void CoinCopyDisp (register const int *src, 
00199                           register int num, 
00200                           register int *dst, 
00201                           register int displacement) {
00202   while (num--)
00203     *dst++ = *src++ + displacement;
00204 }
00205 
00206 }
00207 
00208 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 2 Aug 2012 for Couenne by  doxygen 1.6.1