CouenneCutGenerator.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneCutGenerator.hpp 223 2009-07-09 21:51:16Z pbelotti $
00002  *
00003  * Name:    CouenneCutGenerator.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: a convexification cut generator for MINLP problems
00006  *
00007  * (C) Carnegie-Mellon University, 2006-09.
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #ifndef COUENNE_CUT_GENERATOR_HPP
00012 #define COUENNE_CUT_GENERATOR_HPP
00013 
00014 #include "BonRegisteredOptions.hpp"
00015 
00016 #include "BonOaDecBase.hpp"
00017 #include "CglCutGenerator.hpp"
00018 #include "OsiRowCut.hpp"
00019 #include "BonAuxInfos.hpp"
00020 #include "BonBabInfos.hpp"
00021 #include "OsiSolverInterface.hpp"
00022 
00023 #include "CouenneTypes.hpp"
00024 #include "CouenneJournalist.hpp"
00025 
00026 class CouenneProblem;
00027 class funtriplet;
00028 
00029 //template <class T> class CouenneSolverInterface;
00030 
00031 struct ASL;
00032 
00034 
00035 class CouenneCutGenerator: public CglCutGenerator {
00036 
00037  protected:
00038 
00041   mutable bool firstcall_;
00042 
00045   mutable bool addviolated_;
00046 
00048   enum conv_type convtype_;
00049 
00051   int nSamples_;
00052 
00054   CouenneProblem *problem_;
00055 
00057   mutable int nrootcuts_;
00058 
00060   mutable int ntotalcuts_;
00061 
00063   mutable double septime_;
00064 
00066   mutable double objValue_;
00067 
00070   Bonmin::OsiTMINLPInterface *nlp_;
00071 
00074   Bonmin::Bab *BabPtr_;
00075 
00077   mutable bool infeasNode_;
00078 
00080   JnlstPtr jnlst_;
00081 
00083   mutable double rootTime_;
00084 
00087   bool check_lp_;
00088 
00091   bool enable_lp_implied_bounds_;
00092 
00093  public:
00094 
00096   CouenneCutGenerator  (Bonmin::OsiTMINLPInterface * = NULL,
00097                         Bonmin::BabSetupBase *base = NULL,
00098                         CouenneProblem * = NULL,
00099                         struct ASL * = NULL);
00100 
00102   CouenneCutGenerator  (const CouenneCutGenerator &);
00103 
00105   ~CouenneCutGenerator ();
00106 
00108   CouenneCutGenerator *clone () const
00109   {return new CouenneCutGenerator (*this);}
00110 
00112   inline CouenneProblem *Problem () const
00113   {return problem_;}
00114 
00116   inline void setProblem (CouenneProblem *p)
00117   {problem_ = p;}
00118 
00120   int getnvars () const;
00121 
00123   inline bool isFirst () const 
00124   {return firstcall_;}
00125 
00127   inline bool addViolated () const
00128   {return addviolated_;}
00129 
00131   inline enum conv_type ConvType () const
00132   {return convtype_;}
00133 
00135   inline int nSamples () const
00136   {return nSamples_;}
00137 
00139   void generateCuts (const OsiSolverInterface &, 
00140                      OsiCuts &, 
00141                      const CglTreeInfo = CglTreeInfo ()) const;
00142 
00144   int createCut (OsiCuts &, // cutset to insert
00145                  CouNumber, // lb
00146                  CouNumber, // ub
00147                             // index, coeff  (index -1: "don't care") 
00148                  int,    CouNumber,    // of first  term
00149                  int=-1, CouNumber=0., // of second term 
00150                  int=-1, CouNumber=0., // of third  term
00151                  bool = false) const;  // is it a global cut? No, by default
00152 
00154   int createCut (OsiCuts &, // cutset to insert
00155                  CouNumber, // rhs
00156                  int,       // sign: -1: <=, 0: =, +1: >=
00157                             // index, coeff  (index -1: "don't care") 
00158                  int,    CouNumber,    // of first  term
00159                  int=-1, CouNumber=0., // of second term 
00160                  int=-1, CouNumber=0., // of third  term
00161                  bool = false) const;  // is it a global cut? No, by default
00162 
00166   void addEnvelope (OsiCuts &,
00167                     int,
00168                     unary_function, unary_function, 
00169                     int, int, 
00170                     CouNumber, CouNumber, CouNumber,
00171                     t_chg_bounds * = NULL,
00172                     bool = false) const;
00173 
00177   void addEnvelope (OsiCuts &,
00178                     int,
00179                     funtriplet *,
00180                     int, int, 
00181                     CouNumber, CouNumber, CouNumber,
00182                     t_chg_bounds * = NULL,
00183                     bool = false) const;
00184 
00187   int addSegment (OsiCuts &, int, int,
00188                   CouNumber, CouNumber, 
00189                   CouNumber, CouNumber, int) const;
00190 
00192   int addTangent (OsiCuts &, int, int, 
00193                   CouNumber, CouNumber, 
00194                   CouNumber, int) const; 
00195 
00197   void setBabPtr (Bonmin::Bab *p)
00198   {BabPtr_ = p;}
00199 
00201   void getStats (int &nrc, int &ntc, double &st) {
00202     nrc = nrootcuts_;
00203     ntc = ntotalcuts_;
00204     st  = septime_;
00205   }
00206 
00208   bool &infeasNode () const
00209   {return infeasNode_;}
00210 
00212   void genRowCuts (const OsiSolverInterface &, OsiCuts &cs, 
00213                    int, int *, t_chg_bounds * = NULL) const;
00214 
00216   void genColCuts (const OsiSolverInterface &, OsiCuts &, int, int *) const;
00217 
00219   static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00220 
00222   inline ConstJnlstPtr Jnlst() const 
00223   {return ConstPtr (jnlst_);}
00224 
00225   void setJnlst(JnlstPtr jnlst__)
00226   { jnlst_ = jnlst__; }
00227 
00229   double &rootTime ()
00230   {return rootTime_;}
00231 
00233   bool check_lp () const
00234   {return check_lp_;}
00235 
00237   bool enableLpImpliedBounds () const
00238   {return enable_lp_implied_bounds_;}
00239 };
00240 
00241 
00243 void sparse2dense (int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged);
00244 
00245 #endif

Generated on Wed Jan 20 03:03:55 2010 for Couenne by  doxygen 1.4.7