/home/coin/SVN-release/OS-2.0.0/Couenne/src/disjunctive/CouenneDisjCuts.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneDisjCuts.hpp 141 2009-06-03 04:19:19Z 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 Common Public License (CPL)
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 class CouenneCutGenerator;
00026 class CouenneSolverInterface;
00027 
00028 enum {COUENNE_INFEASIBLE, COUENNE_TIGHTENED, COUENNE_FEASIBLE};
00029 
00031 
00032 class CouenneDisjCuts: public CglCutGenerator {
00033 
00034  protected:
00035 
00037   CouenneCutGenerator *couenneCG_;
00038 
00040   mutable int nrootcuts_;
00041 
00043   mutable int ntotalcuts_;
00044 
00046   mutable double septime_;
00047 
00049   mutable double objValue_;
00050 
00053   Bonmin::OsiTMINLPInterface *minlp_;
00054 
00056   OsiChooseVariable *branchingMethod_;
00057 
00059   bool isBranchingStrong_;
00060 
00062   JnlstPtr jnlst_;
00063 
00065   mutable int numDisjunctions_;
00066 
00068   double initDisjPercentage_;
00069 
00071   int initDisjNumber_;
00072 
00074   int depthLevelling_;
00075 
00077   int depthStopSeparate_;
00078 
00080   bool activeRows_;
00081 
00083   bool activeCols_;
00084 
00086   bool addPreviousCut_;
00087 
00089   double cpuTime_;
00090 
00091  public:
00092 
00094   CouenneDisjCuts (Bonmin::OsiTMINLPInterface *minlp = NULL,
00095                    Bonmin::BabSetupBase *base = NULL,
00096                    CouenneCutGenerator *cg = NULL,
00097                    OsiChooseVariable *bcv = NULL,
00098                    bool is_strong = false,
00099                    JnlstPtr journalist = NULL,
00100                    const Ipopt::SmartPtr<Ipopt::OptionsList> options = NULL);
00101 
00103   CouenneDisjCuts (const CouenneDisjCuts &);
00104 
00106   ~CouenneDisjCuts () {}
00107 
00109   CouenneDisjCuts *clone () const
00110   {return new CouenneDisjCuts (*this);}
00111 
00113   inline CouenneCutGenerator *couenneCG () const
00114   {return couenneCG_;}
00115 
00117   void generateCuts (const OsiSolverInterface &, 
00118                      OsiCuts &, 
00119                      const CglTreeInfo = CglTreeInfo ()) const;
00120 
00122   static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00123 
00125   inline ConstJnlstPtr Jnlst() const 
00126   {return ConstPtr (jnlst_);}
00127 
00129   int getDisjunctions (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjunctions, 
00130                        OsiSolverInterface &si, 
00131                        OsiCuts &cs, 
00132                        const CglTreeInfo &info) const;
00133 
00135   int separateWithDisjunction (OsiCuts *cuts,
00136                                OsiSolverInterface &si, 
00137                                OsiCuts &cs, 
00138                                const CglTreeInfo &info) const;
00139 
00141   int generateDisjCuts (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjs, 
00142                        OsiSolverInterface &si, 
00143                        OsiCuts &cs, 
00144                         const CglTreeInfo &info) const;
00145 
00147   int checkDisjSide (OsiSolverInterface &si, OsiCuts *cuts) const;
00148 
00150   int getBoxUnion (OsiSolverInterface &si, 
00151                    OsiCuts *left, OsiCuts *right, 
00152                    CoinPackedVector &lower, CoinPackedVector &upper) const;
00153 
00154 protected:
00155 
00157   OsiCuts *getSingleDisjunction (OsiSolverInterface &si) const;
00158 
00160   void mergeBoxes (int dir,                        // direction (negative for "<", positive for ">")
00161                    CoinPackedVector &left,         // input
00162                    CoinPackedVector &right,        // input
00163                    CoinPackedVector merged) const; // output  
00164 
00166   void applyColCuts (OsiSolverInterface &si,
00167                      OsiCuts *cuts) const;
00168 
00170   void applyColCuts (OsiSolverInterface &si, 
00171                      OsiColCut *cut) const;
00172 
00173   // construct reduced, standard form matrix M from coefficient matrix of si
00174   void OsiSI2MatrVec (CoinPackedMatrix &M,
00175                       CoinPackedVector &r,
00176                       OsiSolverInterface &si) const;
00177 
00180   int OsiCuts2MatrVec (OsiSolverInterface *cglp,
00181                        OsiCuts *cuts,
00182                        int displRow,
00183                        int displRhs) const;
00184 };
00185 
00186 
00188 inline void CoinInvN (register const double *orig, 
00189                       register int n, 
00190                       register double *inverted) {
00191 
00192   while (n--) *inverted++ = - *orig++;
00193 }
00194 
00195 
00197 inline void CoinCopyDisp (register const int *src, 
00198                           register int num, 
00199                           register int *dst, 
00200                           register int displacement) {
00201   while (num--)
00202     *dst++ = *src++ + displacement;
00203 }
00204 
00205 #endif

Generated on Mon Aug 3 03:02:19 2009 by  doxygen 1.4.7