CouenneExprDiv.hpp

Go to the documentation of this file.
00001 /* $Id: CouenneExprDiv.hpp 615 2011-06-08 20:36:24Z pbelotti $
00002  *
00003  * Name:    exprDiv.hpp
00004  * Author:  Pietro Belotti
00005  * Purpose: definition of divisions
00006  *
00007  * (C) Carnegie-Mellon University, 2006-10.
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #ifndef COUENNE_EXPRDIV_HPP
00012 #define COUENNE_EXPRDIV_HPP
00013 
00014 #include "CouenneExprOp.hpp"
00015 #include "CouennePrecisions.hpp"
00016 
00017 namespace Couenne {
00018 
00019 #define BR_NEXT_ZERO 1e-3
00020 #define BR_MULT      1e-3
00021 
00023 
00024 class exprDiv: public exprOp {
00025 
00026  public:
00027 
00029   exprDiv (expression **al, int n = 2): 
00030     exprOp (al, n) {} //< non-leaf expression, with argument list
00031 
00033   exprDiv (expression *arg0, expression *arg1):
00034     exprOp (arg0, arg1) {}
00035 
00037   expression *clone (Domain *d = NULL) const
00038     {return new exprDiv (clonearglist (d), nargs_);}
00039 
00041   std::string printOp () const
00042     {return "/";}
00043 
00045   inline CouNumber operator () ();
00046 
00048   CouNumber gradientNorm (const double *x);
00049 
00051   expression *differentiate (int index); 
00052 
00054   expression *simplify ();
00055 
00057   inline int Linearity () {
00058 
00059     if (arglist_ [1] -> Type () == CONST)
00060       return arglist_ [0] -> Linearity ();
00061     else return NONLINEAR;
00062   }
00063 
00065   void getBounds (expression *&lb, expression *&ub);
00066 
00068   void getBounds (CouNumber &lb, CouNumber &ub);
00069 
00072   exprAux *standardize (CouenneProblem *p, bool addAux = true);
00073 
00075   void generateCuts (expression *w, //const OsiSolverInterface &si, 
00076                      OsiCuts &cs, const CouenneCutGenerator *cg, 
00077                      t_chg_bounds * = NULL, int = -1, 
00078                      CouNumber = -COUENNE_INFINITY, 
00079                      CouNumber =  COUENNE_INFINITY);
00080 
00082   virtual enum expr_type code () {return COU_EXPRDIV;}
00083 
00085   bool isInteger ();
00086 
00088   bool impliedBound (int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign = expression::AUX_EQ);
00089 
00092   virtual CouNumber selectBranch (const CouenneObject *obj, 
00093                                   const OsiBranchingInformation *info,
00094                                   expression * &var, 
00095                                   double * &brpts, 
00096                                   double * &brDist, // distance of current LP
00097                                                     // point to new convexifications
00098                                   int &way);
00099 
00101   virtual void closestFeasible (expression *varind,
00102                                 expression *vardep, 
00103                                 CouNumber &left,
00104                                 CouNumber &right) const;
00105 
00108   virtual bool isCuttable (CouenneProblem *problem, int index) const
00109   {return false;} // concave on both sides, as for products
00110 };
00111 
00112 
00114 
00115 inline CouNumber exprDiv::operator () ()
00116   {return ((*(*arglist_)) () / (*(arglist_ [1])) ());}
00117 
00118 
00119 #define SAFE_COEFFICIENT 1e9
00120 
00123 
00124 inline bool is_boundbox_regular (register CouNumber b1, register CouNumber b2) {
00125 
00126   // Why SAFE_COEFFICIENT and not COUENNE_INFINITY? Because
00127   // OsiRowCut::set[LU]b do not work for values more than
00128   // SAFE_COEFFICIENT and apparently makes the convexification
00129   // infeasible.
00130   return 
00131     (fabs (b1)    < SAFE_COEFFICIENT) && 
00132     (fabs (b2)    < SAFE_COEFFICIENT) && 
00133     (fabs (b1*b2) < SAFE_COEFFICIENT);
00134     //    && ((fabs (b1) > COUENNE_EPS) || (fabs (b2) > COUENNE_EPS));
00135 }
00136 
00137 }
00138 
00139 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 6 Apr 2015 for Couenne by  doxygen 1.6.1