CouenneCutGenerator.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneCutGenerator.hpp 772 2011-09-03 13:54:49Z stefan $
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 #include "CouenneConfig.h"
00023 #include "CouenneJournalist.hpp"
00024 #include "CouenneTypes.hpp"
00025 
00026 namespace Ipopt {
00027   template <class T> class SmartPtr;
00028   class OptionsList;
00029   class Journalist;
00030 }
00031 
00032 namespace Bonmin {
00033   class RegisteredOptions;
00034   class BabInfo;
00035   class OsiTMINLPInterface;
00036   class BabSetupBase;
00037 }
00038 
00039 struct ASL;
00040 
00041 namespace Couenne {
00042 
00043 class CouenneProblem;
00044 class funtriplet;
00045 
00047 
00048 class CouenneCutGenerator: public CglCutGenerator {
00049 
00050  protected:
00051 
00054   mutable bool firstcall_;
00055 
00058   mutable bool addviolated_;
00059 
00061   enum conv_type convtype_;
00062 
00064   int nSamples_;
00065 
00067   CouenneProblem *problem_;
00068 
00070   mutable int nrootcuts_;
00071 
00073   mutable int ntotalcuts_;
00074 
00076   mutable double septime_;
00077 
00079   mutable double objValue_;
00080 
00083   Bonmin::OsiTMINLPInterface *nlp_;
00084 
00087   Bonmin::Bab *BabPtr_;
00088 
00090   mutable bool infeasNode_;
00091 
00093   JnlstPtr jnlst_;
00094 
00096   mutable double rootTime_;
00097 
00100   bool check_lp_;
00101 
00104   bool enable_lp_implied_bounds_;
00105 
00107   mutable int lastPrintLine;
00108 
00109  public:
00110 
00112   CouenneCutGenerator  (Bonmin::OsiTMINLPInterface * = NULL,
00113                         Bonmin::BabSetupBase *base = NULL,
00114                         CouenneProblem * = NULL,
00115                         struct ASL * = NULL);
00116 
00118   CouenneCutGenerator  (const CouenneCutGenerator &);
00119 
00121   ~CouenneCutGenerator ();
00122 
00124   CouenneCutGenerator *clone () const
00125   {return new CouenneCutGenerator (*this);}
00126 
00128   inline CouenneProblem *Problem () const
00129   {return problem_;}
00130 
00132   inline void setProblem (CouenneProblem *p)
00133   {problem_ = p;}
00134 
00136   int getnvars () const;
00137 
00139   inline bool isFirst () const 
00140   {return firstcall_;}
00141 
00143   inline bool addViolated () const
00144   {return addviolated_;}
00145 
00147   inline enum conv_type ConvType () const
00148   {return convtype_;}
00149 
00151   inline int nSamples () const
00152   {return nSamples_;}
00153 
00155   void generateCuts (const OsiSolverInterface &, 
00156                      OsiCuts &, 
00157                      const CglTreeInfo = CglTreeInfo ()) const;
00158 
00160   int createCut (OsiCuts &, // cutset to insert
00161                  CouNumber, // lb
00162                  CouNumber, // ub
00163                             // index, coeff  (index -1: "don't care") 
00164                  int,    CouNumber,    // of first  term
00165                  int=-1, CouNumber=0., // of second term 
00166                  int=-1, CouNumber=0., // of third  term
00167                  bool = false) const;  // is it a global cut? No, by default
00168 
00170   int createCut (OsiCuts &, // cutset to insert
00171                  CouNumber, // rhs
00172                  int,       // sign: -1: <=, 0: =, +1: >=
00173                             // index, coeff  (index -1: "don't care") 
00174                  int,    CouNumber,    // of first  term
00175                  int=-1, CouNumber=0., // of second term 
00176                  int=-1, CouNumber=0., // of third  term
00177                  bool = false) const;  // is it a global cut? No, by default
00178 
00182   void addEnvelope (OsiCuts &,
00183                     int,
00184                     unary_function, unary_function, 
00185                     int, int, 
00186                     CouNumber, CouNumber, CouNumber,
00187                     t_chg_bounds * = NULL,
00188                     bool = false) const;
00189 
00193   void addEnvelope (OsiCuts &,
00194                     int,
00195                     funtriplet *,
00196                     int, int, 
00197                     CouNumber, CouNumber, CouNumber,
00198                     t_chg_bounds * = NULL,
00199                     bool = false) const;
00200 
00203   int addSegment (OsiCuts &, int, int,
00204                   CouNumber, CouNumber, 
00205                   CouNumber, CouNumber, int) const;
00206 
00208   int addTangent (OsiCuts &, int, int, 
00209                   CouNumber, CouNumber, 
00210                   CouNumber, int) const; 
00211 
00213   void setBabPtr (Bonmin::Bab *p)
00214   {BabPtr_ = p;}
00215 
00217   void getStats (int &nrc, int &ntc, double &st) {
00218     nrc = nrootcuts_;
00219     ntc = ntotalcuts_;
00220     st  = septime_;
00221   }
00222 
00224   bool &infeasNode () const
00225   {return infeasNode_;}
00226 
00228   void genRowCuts (const OsiSolverInterface &, OsiCuts &cs, 
00229                    int, int *, t_chg_bounds * = NULL) const;
00230 
00232   void genColCuts (const OsiSolverInterface &, OsiCuts &, int, int *) const;
00233 
00235   static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00236 
00238   void printLineInfo() const;
00239 
00241   inline ConstJnlstPtr Jnlst() const 
00242   {return ConstPtr (jnlst_);}
00243 
00244   void setJnlst (JnlstPtr jnlst__)
00245   { jnlst_ = jnlst__; }
00246 
00248   double &rootTime ()
00249   {return rootTime_;}
00250 
00252   bool check_lp () const
00253   {return check_lp_;}
00254 
00256   bool enableLpImpliedBounds () const
00257   {return enable_lp_implied_bounds_;}
00258 };
00259 
00260 
00262 void sparse2dense (int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged);
00263 
00264 }
00265 
00266 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Feb 2012 for Couenne by  doxygen 1.6.1