# CouenneCutGenerator.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneCutGenerator.hpp 945 2013-04-06 20:25:21Z 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 "CglConfig.h"
    00018 #include "CglCutGenerator.hpp"
    00019 #include "OsiRowCut.hpp"
    00020 #include "BonAuxInfos.hpp"
    00021 #include "BonBabInfos.hpp"
    00022 #include "OsiSolverInterface.hpp"
    00023 #include "CouenneConfig.h"
    00024 #include "CouenneJournalist.hpp"
    00025 #include "CouenneTypes.hpp"
    00026
    00027 namespace Ipopt {
    00028   template <class T> class SmartPtr;
    00029   class OptionsList;
    00030   class Journalist;
    00031 }
    00032
    00033 namespace Bonmin {
    00034   class RegisteredOptions;
    00035   class BabInfo;
    00036   class OsiTMINLPInterface;
    00037   class BabSetupBase;
    00038 }
    00039
    00040 struct ASL;
    00041
    00042 namespace Couenne {
    00043
    00044 class CouenneProblem;
    00045 class funtriplet;
    00046
    00048
    00049 class CouenneCutGenerator: public CglCutGenerator {
    00050
    00051  protected:
    00052
    00055   mutable bool firstcall_;
    00056
    00059   mutable bool addviolated_;
    00060
    00062   enum conv_type convtype_;
    00063
    00065   int nSamples_;
    00066
    00068   CouenneProblem *problem_;
    00069
    00071   mutable int nrootcuts_;
    00072
    00074   mutable int ntotalcuts_;
    00075
    00077   mutable double septime_;
    00078
    00080   mutable double objValue_;
    00081
    00084   Bonmin::OsiTMINLPInterface *nlp_;
    00085
    00088   Bonmin::Bab *BabPtr_;
    00089
    00091   mutable bool infeasNode_;
    00092
    00094   JnlstPtr jnlst_;
    00095
    00097   mutable double rootTime_;
    00098
    00101   bool check_lp_;
    00102
    00105   bool enable_lp_implied_bounds_;
    00106
    00108   mutable int lastPrintLine;
    00109
    00110  public:
    00111
    00113   CouenneCutGenerator  (Bonmin::OsiTMINLPInterface * = NULL,
    00114                         Bonmin::BabSetupBase *base = NULL,
    00115                         CouenneProblem * = NULL,
    00116                         struct ASL * = NULL);
    00117
    00119   CouenneCutGenerator  (const CouenneCutGenerator &);
    00120
    00122   ~CouenneCutGenerator ();
    00123
    00125   CouenneCutGenerator *clone () const
    00126   {return new CouenneCutGenerator (*this);}
    00127
    00129   inline CouenneProblem *Problem () const
    00130   {return problem_;}
    00131
    00133   inline void setProblem (CouenneProblem *p)
    00134   {problem_ = p;}
    00135
    00137   int getnvars () const;
    00138
    00140   inline bool isFirst () const
    00141   {return firstcall_;}
    00142
    00144   inline bool addViolated () const
    00145   {return addviolated_;}
    00146
    00148   inline enum conv_type ConvType () const
    00149   {return convtype_;}
    00150
    00152   inline int nSamples () const
    00153   {return nSamples_;}
    00154
    00156   void generateCuts (const OsiSolverInterface &,
    00157                      OsiCuts &,
    00158                      const CglTreeInfo = CglTreeInfo ())
    00159 #if CGL_VERSION_MAJOR == 0 && CGL_VERSION_MINOR <= 57
    00160    const
    00161 #endif
    00162   ;
    00163
    00165   int createCut (OsiCuts &, // cutset to insert
    00166                  CouNumber, // lb
    00167                  CouNumber, // ub
    00168                             // index, coeff  (index -1: "don't care")
    00169                  int,    CouNumber,    // of first  term
    00170                  int=-1, CouNumber=0., // of second term
    00171                  int=-1, CouNumber=0., // of third  term
    00172                  bool = false) const;  // is it a global cut? No, by default
    00173
    00175   int createCut (OsiCuts &, // cutset to insert
    00176                  CouNumber, // rhs
    00177                  int,       // sign: -1: <=, 0: =, +1: >=
    00178                             // index, coeff  (index -1: "don't care")
    00179                  int,    CouNumber,    // of first  term
    00180                  int=-1, CouNumber=0., // of second term
    00181                  int=-1, CouNumber=0., // of third  term
    00182                  bool = false) const;  // is it a global cut? No, by default
    00183
    00187   void addEnvelope (OsiCuts &,
    00188                     int,
    00189                     unary_function, unary_function,
    00190                     int, int,
    00191                     CouNumber, CouNumber, CouNumber,
    00192                     t_chg_bounds * = NULL,
    00193                     bool = false) const;
    00194
    00198   void addEnvelope (OsiCuts &,
    00199                     int,
    00200                     funtriplet *,
    00201                     int, int,
    00202                     CouNumber, CouNumber, CouNumber,
    00203                     t_chg_bounds * = NULL,
    00204                     bool = false) const;
    00205
    00208   int addSegment (OsiCuts &, int, int,
    00209                   CouNumber, CouNumber,
    00210                   CouNumber, CouNumber, int) const;
    00211
    00213   int addTangent (OsiCuts &, int, int,
    00214                   CouNumber, CouNumber,
    00215                   CouNumber, int) const;
    00216
    00218   void setBabPtr (Bonmin::Bab *p)
    00219   {BabPtr_ = p;}
    00220
    00222   void getStats (int &nrc, int &ntc, double &st) {
    00223     nrc = nrootcuts_;
    00224     ntc = ntotalcuts_;
    00225     st  = septime_;
    00226   }
    00227
    00229   bool &infeasNode () const
    00230   {return infeasNode_;}
    00231
    00233   void genRowCuts (const OsiSolverInterface &, OsiCuts &cs,
    00234                    int, int *, t_chg_bounds * = NULL) const;
    00235
    00237   void genColCuts (const OsiSolverInterface &, OsiCuts &, int, int *) const;
    00238
    00240   static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
    00241
    00243   void printLineInfo() const;
    00244
    00246   inline ConstJnlstPtr Jnlst() const
    00247   {return ConstPtr (jnlst_);}
    00248
    00249   void setJnlst (JnlstPtr jnlst__)
    00250   { jnlst_ = jnlst__; }
    00251
    00253   double &rootTime ()
    00254   {return rootTime_;}
    00255
    00257   bool check_lp () const
    00258   {return check_lp_;}
    00259
    00261   bool enableLpImpliedBounds () const
    00262   {return enable_lp_implied_bounds_;}
    00263 };
    00264
    00265
    00267 void sparse2dense (int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged);
    00268
    00269 }
    00270
    00271 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines