exprDiv.hpp

Go to the documentation of this file.
00001 /* $Id: exprDiv.hpp 217 2009-07-08 17:02:07Z pbelotti $
00002  *
00003  * Name:    exprDiv.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: definition of divisions
00006  *
00007  * (C) Carnegie-Mellon University, 2006-09.
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #ifndef COUENNE_EXPRDIV_HPP
00012 #define COUENNE_EXPRDIV_HPP
00013 
00014 #include "exprOp.hpp"
00015 #include "CouennePrecisions.hpp"
00016 
00017 #define BR_NEXT_ZERO 1e-3
00018 #define BR_MULT      1e-3
00019 
00020 
00022 
00023 class exprDiv: public exprOp {
00024 
00025  public:
00026 
00028   exprDiv (expression **al, int n = 2): 
00029     exprOp (al, n) {} //< non-leaf expression, with argument list
00030 
00032   exprDiv (expression *arg0, expression *arg1):
00033     exprOp (arg0, arg1) {}
00034 
00036   expression *clone (Domain *d = NULL) const
00037     {return new exprDiv (clonearglist (d), nargs_);}
00038 
00040   std::string printOp () const
00041     {return "/";}
00042 
00044   inline CouNumber operator () ();
00045 
00047   CouNumber gradientNorm (const double *x);
00048 
00050   expression *differentiate (int index); 
00051 
00053   expression *simplify ();
00054 
00056   inline int Linearity () {
00057 
00058     if (arglist_ [1] -> Type () == CONST)
00059       return arglist_ [0] -> Linearity ();
00060     else return NONLINEAR;
00061   }
00062 
00064   void getBounds (expression *&lb, expression *&ub);
00065 
00067   void getBounds (CouNumber &lb, CouNumber &ub);
00068 
00071   exprAux *standardize (CouenneProblem *p, bool addAux = true);
00072 
00074   void generateCuts (expression *w, //const OsiSolverInterface &si, 
00075                      OsiCuts &cs, const CouenneCutGenerator *cg, 
00076                      t_chg_bounds * = NULL, int = -1, 
00077                      CouNumber = -COUENNE_INFINITY, 
00078                      CouNumber =  COUENNE_INFINITY);
00079 
00081   virtual enum expr_type code () {return COU_EXPRDIV;}
00082 
00084   bool isInteger ();
00085 
00087   bool impliedBound (int, CouNumber *, CouNumber *, t_chg_bounds *);
00088 
00091   virtual CouNumber selectBranch (const CouenneObject *obj, 
00092                                   const OsiBranchingInformation *info,
00093                                   expression * &var, 
00094                                   double * &brpts, 
00095                                   double * &brDist, // distance of current LP
00096                                                     // point to new convexifications
00097                                   int &way);
00098 
00100   virtual void closestFeasible (expression *varind,
00101                                 expression *vardep, 
00102                                 CouNumber &left,
00103                                 CouNumber &right) const;
00104 
00107   virtual bool isCuttable (CouenneProblem *problem, int index) const
00108   {return false;} // concave on both sides, as for products
00109 };
00110 
00111 
00113 
00114 inline CouNumber exprDiv::operator () ()
00115   {return ((*(*arglist_)) () / (*(arglist_ [1])) ());}
00116 
00117 
00118 #define SAFE_COEFFICIENT 1e9
00119 
00122 
00123 inline bool is_boundbox_regular (register CouNumber b1, register CouNumber b2) {
00124 
00125   // Why SAFE_COEFFICIENT and not COUENNE_INFINITY? Because
00126   // OsiRowCut::set[LU]b do not work for values more than
00127   // SAFE_COEFFICIENT and apparently makes the convexification
00128   // infeasible.
00129   return 
00130     (fabs (b1)    < SAFE_COEFFICIENT) && 
00131     (fabs (b2)    < SAFE_COEFFICIENT) && 
00132     (fabs (b1*b2) < SAFE_COEFFICIENT);
00133     //    && ((fabs (b1) > COUENNE_EPS) || (fabs (b2) > COUENNE_EPS));
00134 }
00135 
00136 #endif

Generated on Sun Mar 6 03:03:41 2011 for Couenne by  doxygen 1.4.7