CouenneCutGenerator.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneCutGenerator.hpp 574 2011-05-10 10:00:24Z fmargot $
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 Eclipse Public License (EPL)
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 #undef PACKAGE
00024 #undef PACKAGE_BUGREPORT
00025 #undef PACKAGE_VERSION
00026 #undef PACKAGE_TARNAME
00027 #undef PACKAGE_NAME
00028 #undef PACKAGE_STRING
00029 #undef VERSION
00030 
00031 #include "CouenneJournalist.hpp"
00032 
00033 #undef PACKAGE
00034 #undef PACKAGE_BUGREPORT
00035 #undef PACKAGE_VERSION
00036 #undef PACKAGE_TARNAME
00037 #undef PACKAGE_NAME
00038 #undef PACKAGE_STRING
00039 #undef VERSION
00040 
00041 #include "config_couenne.h"
00042 
00043 #include "CouenneTypes.hpp"
00044 
00045 namespace Ipopt {
00046   template <class T> class SmartPtr;
00047   class OptionsList;
00048   class Journalist;
00049 }
00050 
00051 namespace Bonmin {
00052   class RegisteredOptions;
00053   class BabInfo;
00054   class OsiTMINLPInterface;
00055   class BabSetupBase;
00056 }
00057 
00058 struct ASL;
00059 
00060 namespace Couenne {
00061 
00062 class CouenneProblem;
00063 class funtriplet;
00064 
00066 
00067 class CouenneCutGenerator: public CglCutGenerator {
00068 
00069  protected:
00070 
00073   mutable bool firstcall_;
00074 
00077   mutable bool addviolated_;
00078 
00080   enum conv_type convtype_;
00081 
00083   int nSamples_;
00084 
00086   CouenneProblem *problem_;
00087 
00089   mutable int nrootcuts_;
00090 
00092   mutable int ntotalcuts_;
00093 
00095   mutable double septime_;
00096 
00098   mutable double objValue_;
00099 
00102   Bonmin::OsiTMINLPInterface *nlp_;
00103 
00106   Bonmin::Bab *BabPtr_;
00107 
00109   mutable bool infeasNode_;
00110 
00112   JnlstPtr jnlst_;
00113 
00115   mutable double rootTime_;
00116 
00119   bool check_lp_;
00120 
00123   bool enable_lp_implied_bounds_;
00124 
00126   mutable int lastPrintLine;
00127 
00128  public:
00129 
00131   CouenneCutGenerator  (Bonmin::OsiTMINLPInterface * = NULL,
00132                         Bonmin::BabSetupBase *base = NULL,
00133                         CouenneProblem * = NULL,
00134                         struct ASL * = NULL);
00135 
00137   CouenneCutGenerator  (const CouenneCutGenerator &);
00138 
00140   ~CouenneCutGenerator ();
00141 
00143   CouenneCutGenerator *clone () const
00144   {return new CouenneCutGenerator (*this);}
00145 
00147   inline CouenneProblem *Problem () const
00148   {return problem_;}
00149 
00151   inline void setProblem (CouenneProblem *p)
00152   {problem_ = p;}
00153 
00155   int getnvars () const;
00156 
00158   inline bool isFirst () const 
00159   {return firstcall_;}
00160 
00162   inline bool addViolated () const
00163   {return addviolated_;}
00164 
00166   inline enum conv_type ConvType () const
00167   {return convtype_;}
00168 
00170   inline int nSamples () const
00171   {return nSamples_;}
00172 
00174   void generateCuts (const OsiSolverInterface &, 
00175                      OsiCuts &, 
00176                      const CglTreeInfo = CglTreeInfo ()) const;
00177 
00179   int createCut (OsiCuts &, // cutset to insert
00180                  CouNumber, // lb
00181                  CouNumber, // ub
00182                             // index, coeff  (index -1: "don't care") 
00183                  int,    CouNumber,    // of first  term
00184                  int=-1, CouNumber=0., // of second term 
00185                  int=-1, CouNumber=0., // of third  term
00186                  bool = false) const;  // is it a global cut? No, by default
00187 
00189   int createCut (OsiCuts &, // cutset to insert
00190                  CouNumber, // rhs
00191                  int,       // sign: -1: <=, 0: =, +1: >=
00192                             // index, coeff  (index -1: "don't care") 
00193                  int,    CouNumber,    // of first  term
00194                  int=-1, CouNumber=0., // of second term 
00195                  int=-1, CouNumber=0., // of third  term
00196                  bool = false) const;  // is it a global cut? No, by default
00197 
00201   void addEnvelope (OsiCuts &,
00202                     int,
00203                     unary_function, unary_function, 
00204                     int, int, 
00205                     CouNumber, CouNumber, CouNumber,
00206                     t_chg_bounds * = NULL,
00207                     bool = false) const;
00208 
00212   void addEnvelope (OsiCuts &,
00213                     int,
00214                     funtriplet *,
00215                     int, int, 
00216                     CouNumber, CouNumber, CouNumber,
00217                     t_chg_bounds * = NULL,
00218                     bool = false) const;
00219 
00222   int addSegment (OsiCuts &, int, int,
00223                   CouNumber, CouNumber, 
00224                   CouNumber, CouNumber, int) const;
00225 
00227   int addTangent (OsiCuts &, int, int, 
00228                   CouNumber, CouNumber, 
00229                   CouNumber, int) const; 
00230 
00232   void setBabPtr (Bonmin::Bab *p)
00233   {BabPtr_ = p;}
00234 
00236   void getStats (int &nrc, int &ntc, double &st) {
00237     nrc = nrootcuts_;
00238     ntc = ntotalcuts_;
00239     st  = septime_;
00240   }
00241 
00243   bool &infeasNode () const
00244   {return infeasNode_;}
00245 
00247   void genRowCuts (const OsiSolverInterface &, OsiCuts &cs, 
00248                    int, int *, t_chg_bounds * = NULL) const;
00249 
00251   void genColCuts (const OsiSolverInterface &, OsiCuts &, int, int *) const;
00252 
00254   static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00255 
00257   void printLineInfo() const;
00258 
00260   inline ConstJnlstPtr Jnlst() const 
00261   {return ConstPtr (jnlst_);}
00262 
00263   void setJnlst (JnlstPtr jnlst__)
00264   { jnlst_ = jnlst__; }
00265 
00267   double &rootTime ()
00268   {return rootTime_;}
00269 
00271   bool check_lp () const
00272   {return check_lp_;}
00273 
00275   bool enableLpImpliedBounds () const
00276   {return enable_lp_implied_bounds_;}
00277 };
00278 
00279 
00281 void sparse2dense (int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged);
00282 
00283 }
00284 
00285 #endif

Generated on Mon Aug 8 03:06:40 2011 for Couenne by  doxygen 1.4.7