# CouenneExprInv.hpp

Go to the documentation of this file.

    00001 /* $Id: CouenneExprInv.hpp 615 2011-06-08 20:36:24Z pbelotti $
    00002  *
    00003  * Name:    exprInv.hpp
    00004  * Author:  Pietro Belotti
    00005  * Purpose: definition of inverse of a function (1/f(x))
    00006  *
    00007  * (C) Carnegie-Mellon University, 2006-10.
    00008  * This file is licensed under the Eclipse Public License (EPL)
    00009  */
    00010
    00011 #ifndef COUENNE_EXPRINV_H
    00012 #define COUENNE_EXPRINV_H
    00013
    00014 #include "CouenneExprUnary.hpp"
    00015
    00016 namespace Couenne {
    00017
    00019 inline CouNumber inv (register CouNumber arg)
    00020 {return 1. / arg;}
    00021
    00022
    00024 inline CouNumber oppInvSqr (register CouNumber x)
    00025 {return (- inv (x*x));}
    00026
    00027
    00029 inline CouNumber inv_dblprime (register CouNumber x)
    00030 {return (2 * inv (x*x*x));}
    00031
    00032
    00034
    00035 class exprInv: public exprUnary {
    00036
    00037  public:
    00038
    00040   exprInv (expression *al):
    00041     exprUnary (al) {} //< non-leaf expression, with argument list
    00042
    00044   expression *clone (Domain *d = NULL) const
    00045     {return new exprInv (argument_ -> clone (d));}
    00046
    00048   inline unary_function F () {return inv;}
    00049
    00051   virtual void print (std::ostream &out = std::cout, bool = false) const;
    00052
    00054   CouNumber gradientNorm (const double *x);
    00055
    00057   expression *differentiate (int index);
    00058
    00060   virtual inline int Linearity () {
    00061     if (argument_ -> Type () == CONST) return CONSTANT;
    00062     else                               return NONLINEAR;
    00063   }
    00064
    00066   void getBounds (expression *&, expression *&);
    00067
    00069   void getBounds (CouNumber &lb, CouNumber &ub);
    00070
    00072   void generateCuts (expression *w, //const OsiSolverInterface &si,
    00073                      OsiCuts &cs, const CouenneCutGenerator *cg,
    00074                      t_chg_bounds * = NULL, int = -1,
    00075                      CouNumber = -COUENNE_INFINITY,
    00076                      CouNumber =  COUENNE_INFINITY);
    00077
    00079   virtual enum expr_type code () {return COU_EXPRINV;}
    00080
    00082   bool impliedBound (int, CouNumber *, CouNumber *, t_chg_bounds *, enum auxSign = expression::AUX_EQ);
    00083
    00086   virtual CouNumber selectBranch (const CouenneObject *obj,
    00087                                   const OsiBranchingInformation *info,
    00088                                   expression * &var,
    00089                                   double * &brpts,
    00090                                   double * &brDist, // distance of current LP
    00091                                                     // point to new convexifications
    00092                                   int &way);
    00093
    00095   virtual bool isBijective() const {return true;}
    00096
    00098   virtual CouNumber inverse(expression *vardep) const
    00099   {
    00100     return 1./((*vardep)());
    00101   }
    00102
    00105   virtual bool isCuttable (CouenneProblem *problem, int index) const;
    00106 };
    00107
    00108 }
    00109
    00110 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines