00001
00002
00003
00004
00005
00006
00007
00008
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 CouenneSolverInterface;
00028 class funtriplet;
00029
00030 struct ASL;
00031
00033
00034 class CouenneCutGenerator: public CglCutGenerator {
00035
00036 protected:
00037
00040 mutable bool firstcall_;
00041
00044 mutable bool addviolated_;
00045
00047 enum conv_type convtype_;
00048
00050 int nSamples_;
00051
00053 CouenneProblem *problem_;
00054
00056 mutable int nrootcuts_;
00057
00059 mutable int ntotalcuts_;
00060
00062 mutable double septime_;
00063
00065 mutable double objValue_;
00066
00069 Bonmin::OsiTMINLPInterface *nlp_;
00070
00073 Bonmin::Bab *BabPtr_;
00074
00076 mutable bool infeasNode_;
00077
00079 JnlstPtr jnlst_;
00080
00082 mutable double rootTime_;
00083
00086 bool check_lp_;
00087
00090 bool enable_lp_implied_bounds_;
00091
00092 public:
00093
00095 CouenneCutGenerator (Bonmin::OsiTMINLPInterface * = NULL,
00096 Bonmin::BabSetupBase *base = NULL,
00097 struct ASL * = NULL);
00098
00100 CouenneCutGenerator (const CouenneCutGenerator &);
00101
00103 ~CouenneCutGenerator ();
00104
00106 CouenneCutGenerator *clone () const
00107 {return new CouenneCutGenerator (*this);}
00108
00110 inline CouenneProblem *Problem () const
00111 {return problem_;}
00112
00114 inline void setProblem (CouenneProblem *p)
00115 {problem_ = p;}
00116
00118 int getnvars () const;
00119
00121 inline bool isFirst () const
00122 {return firstcall_;}
00123
00125 inline bool addViolated () const
00126 {return addviolated_;}
00127
00129 inline enum conv_type ConvType () const
00130 {return convtype_;}
00131
00133 inline int nSamples () const
00134 {return nSamples_;}
00135
00137 void generateCuts (const OsiSolverInterface &,
00138 OsiCuts &,
00139 const CglTreeInfo = CglTreeInfo ()) const;
00140
00142 int createCut (OsiCuts &,
00143 CouNumber,
00144 CouNumber,
00145
00146 int, CouNumber,
00147 int=-1, CouNumber=0.,
00148 int=-1, CouNumber=0.,
00149 bool = false) const;
00150
00152 int createCut (OsiCuts &,
00153 CouNumber,
00154 int,
00155
00156 int, CouNumber,
00157 int=-1, CouNumber=0.,
00158 int=-1, CouNumber=0.,
00159 bool = false) const;
00160
00164 void addEnvelope (OsiCuts &,
00165 int,
00166 unary_function, unary_function,
00167 int, int,
00168 CouNumber, CouNumber, CouNumber,
00169 t_chg_bounds * = NULL,
00170 bool = false) const;
00171
00175 void addEnvelope (OsiCuts &,
00176 int,
00177 funtriplet *,
00178 int, int,
00179 CouNumber, CouNumber, CouNumber,
00180 t_chg_bounds * = NULL,
00181 bool = false) const;
00182
00185 int addSegment (OsiCuts &, int, int,
00186 CouNumber, CouNumber,
00187 CouNumber, CouNumber, int) const;
00188
00190 int addTangent (OsiCuts &, int, int,
00191 CouNumber, CouNumber,
00192 CouNumber, int) const;
00193
00195 void setBabPtr (Bonmin::Bab *p)
00196 {BabPtr_ = p;}
00197
00199 void getStats (int &nrc, int &ntc, double &st) {
00200 nrc = nrootcuts_;
00201 ntc = ntotalcuts_;
00202 st = septime_;
00203 }
00204
00206 bool &infeasNode () const
00207 {return infeasNode_;}
00208
00210 void genRowCuts (const OsiSolverInterface &, OsiCuts &cs,
00211 int, int *, t_chg_bounds * = NULL) const;
00212
00214 void genColCuts (const OsiSolverInterface &, OsiCuts &, int, int *) const;
00215
00217 static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00218
00220 inline ConstJnlstPtr Jnlst() const
00221 {return ConstPtr (jnlst_);}
00222
00223 void setJnlst(JnlstPtr jnlst__)
00224 { jnlst_ = jnlst__; }
00225
00227 double &rootTime ()
00228 {return rootTime_;}
00229
00231 bool check_lp () const
00232 {return check_lp_;}
00233
00235 bool enableLpImpliedBounds () const
00236 {return enable_lp_implied_bounds_;}
00237 };
00238
00239
00241 void sparse2dense (int ncols, t_chg_bounds *chg_bds, int *&changed, int &nchanged);
00242
00243 #endif